Sail E0 Webinar

MCQs

Total Questions : 45 | Page 3 of 5 pages
Question 21. Determine Output:
void main()
{
int i=1, j=2;
switch(i)
{
case 1: printf("GOOD"); break;
case j: printf("BAD"); break;
}
}
  1.    GOOD BAD
  2.    GOOD
  3.    Compiler Error
  4.    None of These
 Discuss Question
Answer: Option C. -> Compiler Error
Question 22. Determine Output:
void main()
{
int i;
printf("%d", scanf("%d", &i)); // value 10 is given as input here
}
  1.    10
  2.    1
  3.    Garbage Value
  4.    None of These
 Discuss Question
Answer: Option B. -> 1
Question 23. Determine Output:
void main()
{
int i=0;
for(;i++;printf("%d", i));
printf("%d", i);
}
  1.    1
  2.    11
  3.    12
  4.    Error
 Discuss Question
Answer: Option A. -> 1
Question 24. Determine Output:
void main()
{
struct xx
{
int x=3;
char name[] = "hello";
};
struct xx *s = malloc(sizeof(struct xx));
printf("%d", s->x);
printf("%s", s->name);
}
  1.    3 hello
  2.    Compiler Error
  3.    Linking error
  4.    None of these
 Discuss Question
Answer: Option B. -> Compiler Error
Question 25. Determine output:
void main()
{
extern int i;
i=20;
printf("%d", sizeof(i));
}
  1.    20
  2.    2
  3.    Compiler Error
  4.    Linker Error
 Discuss Question
Answer: Option D. -> Linker Error
Question 26. Determine Output:
void main()
{
int i=0, j=0;
if(i && j++)
printf("%d..%d", i++, j);
printf("%d..%d", i, j);
}
  1.    0..1
  2.    1..0
  3.    0..0
  4.    1..1
 Discuss Question
Answer: Option C. -> 0..0
Question 27. Determine Output:
void main()
{
int i=-1, j=-1, k=0, l=2, m;
m = i++ && j++ && k++ || l++;
printf("%d %d %d %d %d", i, j, k, l, m);
}
  1.    0 0 1 2 0
  2.    0 0 1 3 0
  3.    0 0 1 3 1
  4.    0 0 0 2 1
 Discuss Question
Answer: Option C. -> 0 0 1 3 1
Question 28. Determine Output:
void main()
{
static int i=5;
if(--i){
main();
printf("%d ", i);
}
}
  1.    5 4 3 2 1
  2.    0 0 0 0
  3.    Infinite Loop
  4.    None of These
 Discuss Question
Answer: Option B. -> 0 0 0 0
Question 29. Determine Output:
void main()
{
int i = -1;
+i;
printf("i = %d, +i = %d", i, +i);
}
  1.    i = -1, +i = 1
  2.    i = 1, +i = 1
  3.    i = -1, +i = -1
  4.    None of These
 Discuss Question
Answer: Option C. -> i = -1, +i = -1
Question 30. Determine Output:
void main()
{
char *str1 = "abcd";
char str2[] = "abcd";
printf("%d %d %d", sizeof(str1), sizeof(str2), sizeof("abcd"));
}
  1.    2 5 5
  2.    5 5 5
  3.    2 4 5
  4.    2 4 4
 Discuss Question
Answer: Option A. -> 2 5 5

Latest Videos

Latest Test Papers