Sail E0 Webinar

MCQs

Total Questions : 28 | Page 3 of 3 pages
Question 21. Find the output of the following program.
#include
void main()
{
int y=10;
if(y++>9 && y++!=10 && y++>11)
printf("%d", y);
else
printf("%d", y);
}
  1.    11
  2.    12
  3.    13
  4.    14
  5.    Compilation error
 Discuss Question
Answer: Option C. -> 13
Question 22. What is the right choice, if the following loop is implemented?
void main()
{
int num = 0;
do{
--num;
printf("%d", num);
}while( ++num >= 0 );
}
  1.    A run time error will be generated.
  2.    The program will not enter into the loop.
  3.    There will be a compilation error reported.
  4.    The loop will run infinitely many times.
  5.    Prints the value of 0 one time only.
 Discuss Question
Answer: Option D. -> The loop will run infinitely many times.
Question 23. What will be the value of sum after the following program is executed?
void main()
{
int sum=1, index = 9;
do{
index = index – 1;
sum *= 2;
}while( index > 9 );
}
  1.    1
  2.    2
  3.    9
  4.    0.5
  5.    0.25
 Discuss Question
Answer: Option B. -> 2
Question 24. What will be the following code's output if choice = 'R'?
switch(choice)
{
case 'R' : printf("RED");
case 'W' : printf("WHITE");
case 'B' : printf("BLUE");
default : printf("ERROR");break;
}
  1.    RED
  2.    RED WHITE BLUE ERROR
  3.    RED ERROR
  4.    RED WHITE BLUE
  5.    ERROR
 Discuss Question
Answer: Option B. -> RED WHITE BLUE ERROR
Question 25. What will be the final value of the digit?
void main()
{
int digit = 0;
for( ; digit
  1.    -1
  2.    17
  3.    19
  4.    16
  5.    20
 Discuss Question
Answer: Option C. -> 19
Question 26. Consider the following program fragment:
for(c=1, sum=0; c
  1.    -5
  2.    30
  3.    10
  4.    1
  5.    15
 Discuss Question
Answer: Option E. -> 15
Question 27. What will be printed if the following code is executed?
void main()
{
int x=0;
for( ; ; )
{
if( x++ == 4 ) break;
continue;
}
printf("x=%d", x);
}
  1.    x=0
  2.    x=5
  3.    x=4
  4.    x=1
  5.    Error
 Discuss Question
Answer: Option B. -> x=5
Question 28. Consider the following code:
void main()
{
int a[5] = {6,8,3,9,0}, i=0;
if(i != 0)
{
break;
printf("%d", a[i]);
}
else
printf("%d", a[i++]);
}
What is the output of the above program?
  1.    6
  2.    8
  3.    Runtime error
  4.    Syntax error
  5.    No output
 Discuss Question
Answer: Option D. -> Syntax error

Latest Videos

Latest Test Papers