C Program find Output code snippet SET - 5

What will be the output of the program, if a short int is 2 bytes wide?
#include<stdio.h>
int main()
{
    short int i = 0;
    for(i<=5 && i>=-1; ++i; i>0)
        printf("%u,", i);
    return 0;
}
A.
1 ... 65535
B.
Expression syntax error
C.
No output
D.
0, 1, 2, 3, 4, 5
Workspace

2.
What will be the output of the program?
#include<stdio.h>
int main()
{
    float a = 0.7;
    if(0.7 > a)
        printf("Hi\n");
    else
        printf("Hello\n");
    return 0;
}
A.
Hi
B.
Hello
C.
Hi Hello
D.
None of above
Workspace

3.
Which of the following statements are correct about an if-else statements in a C-program?
1:
Every if-else statement can be replaced by an equivalent statements using   ?: operators
2:
Nested if-else statements are allowed.
3:
Multiple statements in an if block are allowed.
4:
Multiple statements in an else block are allowed.
A.
1 and 2
B.
2 and 3
C.
1, 2 and 4
D.
2, 3, 4
Workspace

4.
Can we use a switch statement to switch on strings?
A.
Yes
B.
No
Workspace

5.
What will be the output of the program?
#include<stdio.h>
#include<math.h>
int main()
{
    printf("%f\n", sqrt(36.0));
    return 0;
}
A.
6.0
B.
6
C.
6.000000
D.
Error: Prototype sqrt() not found.
Workspace

6.
Is it true that too many recursive calls may result into stack overflow?
A.
Yes
B.
No
Workspace

7.
A macro must always be defined in capital letters.
A.
True
B.
False
Workspace

8.
In a macro call the control is passed to the macro.
A.
True
B.
False
Workspace

9.
A header file contains macros, structure declaration and function prototypes.
A.
True
B.
False
Workspace

10.
Which of the following function sets first n characters of a string to a given character?
A.
strinit()
B.
strnset()
C.
strset()
D.
strcset()
Workspace

11.
What will be the output of the program ?
#include<stdio.h>

int main()
{
    char str1[] = "Hello";
    char str2[10];
    char *t, *s;
    s = str1;
    t = str2;
    while(*t=*s)
        *t++ = *s++;
    printf("%s\n", str2);
    return 0;
}
A.
Hello
B.
HelloHello
C.
No output
D.
ello
Workspace

12.
What will be the output of the program ?
#include<stdio.h>

int main()
{
    char str = "IndiaBIX";
    printf("%s\n", str);
    return 0;
}
A.
Error
B.
IndiaBIX
C.
Base address of str
D.
No output
Workspace

13.
If the size of pointer is 4 bytes then What will be the output of the program ?
#include<stdio.h>

int main()
{
    char *str[] = {"Frogs", "Do", "Not", "Die", "They", "Croak!"};
    printf("%d, %d", sizeof(str), strlen(str[0]));
    return 0;
}
A.
22, 4
B.
25, 5
C.
24, 5
D.
20, 2
Workspace

14.
Point out the error in the program?
#include<stdio.h>

int main()
{
    FILE *fp;
    fp=fopen("trial", "r");
    fseek(fp, "20", SEEK_SET);
    fclose(fp);
    return 0;
}
A.
Error: unrecognised Keyword SEEK_SET
B.
Error: fseek() long offset value
C.
No error
D.
None of above
Workspace

15.
What will be the output of the program (myprog.c) given below if it is executed from the command line?
cmd> myprog friday tuesday sunday
/* myprog.c */
#include<stdio.h>

int main(int argc, char *argv[])
{
    printf("%c", *++argv[1]);
    return 0;
}
A.
r
B.
f
C.
m
D.
y
Workspace

16.
What will be the output of the program?
#include<stdio.h>

int main()
{
    const int x=5;
    const int *ptrx;
    ptrx = &x;
    *ptrx = 10;
    printf("%d\n", x);
    return 0;
}
A.
5
B.
10
C.
Error
D.
Garbage value
Workspace

17.
Point out the error in the program (in Turbo-C).
#include<stdio.h>
#define MAX 128

int main()
{
    const int max=128;
    char array[max];
    char string[MAX];
    array[0] = string[0] = 'A';
    printf("%c %c\n", array[0], string[0]);
    return 0;
}
A.
Error: unknown max in declaration/Constant expression required
B.
Error: invalid array string
C.
None of above
D.
No error. It prints A A
Workspace

18.
Point out the error in the program.
#include<stdio.h>
const char *fun();

int main()
{
    char *ptr = fun();
    return 0;
}
const char *fun()
{
    return "Hello";
}
A.
Error: Lvalue required
B.
Error: cannot convert 'const char *' to 'char *'.
C.
No error and No output
D.
None of above
Workspace

19.
Input/output function prototypes and macros are defined in which header file?
A.
conio.h
B.
stdlib.h
C.
stdio.h
D.
dos.h
Workspace

20.
What will be the output of the program?
#include<stdio.h>

int main()
{
    int i;
    char c;
    for(i=1; i<=5; i++)
    {
        scanf("%c", &c); /* given input is 'a' */
        printf("%c", c);
        ungetc(c, stdin);
    }
    return 0;
}
A.
aaaa
B.
aaaaa
C.
Garbage value.
D.
Error in ungetc statement.


Provide your Output in Comments. We will publish the output soon.

Comments

Popular posts from this blog

Tips 01) self introduction in an interview

Computer Science Terminology

Why Failure Is Good for Success