Control Structure Questions and Answers

Practice Mode
Showing 10 of 97 questions
Q81
Find the output void magic (int); void main ( ) { int a=100; magic (a); } void magic (int a) { if (a!=0) { printf ("%c", "abcdefgh" [a%8]); } else printf ("\n"); }
  • A 4
  • B d
  • C bee
  • D e
Answer: Option D
Q82
Find the output void main ( ) { int i=1; for (i, i++<=3;) { switch (i) { case 1: printf("one"); continue; case 2: printf ("two"); break; case 3: printf ("three"); continue; } } }
  • A onetworthree
  • B twothree
  • C No output
  • D Compilation error
Answer: Option B
Q83
Find the output int main (int k) { if (k<5) printf("%d ", main (k+1)); return k; }
  • A 5 4 3 2 1
  • B 5 4 3 2
  • C 4 3 2 1
  • D 4 3 2
Answer: Option B
Q84
Find the output void main ( ) { int i=1, j=-1; if ((printf("%d", i))< (printf("%d", j))) printf ("%d", i); else printf ("%d", j); }
  • A 1 -1 1
  • B 1 -1 -1
  • C 1
  • D -1
Answer: Option A
Q85
Find the output void main ( ) { int i=12; if (i==12) { i=10; } else { i=20; } printf("%d", i); }
  • A 12
  • B 10
  • C Garbage value
  • D Compilation error.
Answer: Option B
Q86
Which of the following is incorrect about a switch statement ?
  • A It is not necessary to use a break in every switch statement.
  • B Compiler implements a jump table for cases used a switch.
  • C Switch is useful to check whether a value falls in different range or not.
  • D Switch is useful to check the value of a variable against a particular set of values.
Answer: Option C
Q87
Find the output void main ( ) { int _if=1, else=5; if (_if==10); else (_else==7); printf ("%d",_else); }
  • A 5
  • B 7
  • C No output
  • D Compilation error
Answer: Option A
Q88
Find the output void main ( ) { while (1) { if (printf("%d", printf ("5d"))) { printf("Hi"); break; } else printf("HoHo"); } }
  • A 10HoHo
  • B 01Hi
  • C Garbage value
  • D None of these
Answer: Option B
Q89
Find the output void main ( ) { int x=0, y=0; if (!x) { y=!x; if (y) x=!y; } printf ("%d %d", x,y); }
  • A 0 0
  • B 1 1
  • C 0 1
  • D 1 0
Answer: Option C
Q90
Find the output void main ( ) { int i=1; switch (i) { case 1; switch (i) printf ("\nFM"); case 1*2+4: printf("Radio"); } }
  • A FM
  • B FMRadio
  • C Radio
  • D Compilation error
Answer: Option C
Questions and Answers for Competitive Exams Various Entrance Test