Control Structure Questions and Answers

Practice Mode
Showing 10 of 97 questions
Q91
Find the output void main ( ) { int x=5; begin: if (x) { printf ("%d", x); x--; goto begin; } }
  • A No output
  • B 5
  • C 54321
  • D Garbage value
Answer: Option C
Q92
Find the output #define a i++ void main ( ) { int i=0; if (0==a); #define a --1 else #define a ++i printf ("%d", a); }
  • A 2
  • B Garbage
  • C No output
  • D Compilation error
Answer: Option C
Q93
Find the output void main ( ) { int a=0; switch (a) { case 0: switch (a) { case 0: goto default; break; case 1: printf ("ho ho"); default : printf ("ha ha"); } case 1: printf ("he he"); default : printf (" "); } }
  • A ha ha he he
  • B ha ha
  • C No output
  • D Compilation error
Answer: Option D
Q94
Find the output void main ( ) { int i; for (i=1; i<=450; i++) printf("Hello"); if (i==10) break; printf("Hi"); }
  • A Hello 10 times
  • B Hello 10 times and hi
  • C Hello 450 times and hi once
  • D Compilation error
Answer: Option D
Q95
Find the output void main ( ) { int i=98; while (100-i++) printf ("%u", i); switch (i) case 'e': printf ("Foo1"); }
  • A 98 99 100
  • B 99 100
  • C 99 100 Foo1
  • D Compilation error
Answer: Option C
Q96
Find the output #define switch case #define if switch void main ( ) { int i=1; if (i) { switch 1: { case 0: printf ("It's magic"); break; } case 2: printf ("\n No magic"); break; case 1*2+4: printf("it's music"); } }
  • A It's magic
  • B No magic
  • C No output
  • D Compilation error
Answer: Option A
Q97
Find the output void main ( ) { int i=10, j=15, k=5; if ((i?j:k)=J%3) printf ("%d",j); }
  • A 5
  • B 15
  • C 3
  • D Compilation error
Answer: Option D
Questions and Answers for Competitive Exams Various Entrance Test