Control Structure Questions and Answers
Control Structure Questions with Answers form the foundation of logic building in C programming. These C programming questions and answers focus on decision-making statements like if-else, switch, loops, and nested conditions. Mastering control structures helps in writing efficient and optimized programs, which is crucial for placements at TCS, Infosys, and Accenture. Practicing control structure MCQs with solutions enables you to solve complex programming tasks confidently. Start your C aptitude preparation now by downloading our free control structure practice questions PDF or attempt the online test for immediate feedback.
Control Structure
Showing 10 of
97 questions
81. 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"); }
- 4
- d
- bee
- e
82. 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; } } }
- onetworthree
- twothree
- No output
- Compilation error
83. Find the output int main (int k) { if (k<5) printf("%d ", main (k+1)); return k; }
- 5 4 3 2 1
- 5 4 3 2
- 4 3 2 1
- 4 3 2
84. Find the output void main ( ) { int i=1, j=-1; if ((printf("%d", i))< (printf("%d", j))) printf ("%d", i); else printf ("%d", j); }
- 1 -1 1
- 1 -1 -1
- 1
- -1
85. Find the output void main ( ) { int i=12; if (i==12) { i=10; } else { i=20; } printf("%d", i); }
- 12
- 10
- Garbage value
- Compilation error.
86. Which of the following is incorrect about a switch statement ?
- It is not necessary to use a break in every switch statement.
- Compiler implements a jump table for cases used a switch.
- Switch is useful to check whether a value falls in different range or not.
- Switch is useful to check the value of a variable against a particular set of values.
87. Find the output void main ( ) { int _if=1, else=5; if (_if==10); else (_else==7); printf ("%d",_else); }
- 5
- 7
- No output
- Compilation error
88. Find the output void main ( ) { while (1) { if (printf("%d", printf ("5d"))) { printf("Hi"); break; } else printf("HoHo"); } }
- 10HoHo
- 01Hi
- Garbage value
- None of these
89. Find the output void main ( ) { int x=0, y=0; if (!x) { y=!x; if (y) x=!y; } printf ("%d %d", x,y); }
- 0 0
- 1 1
- 0 1
- 1 0
90. Find the output void main ( ) { int i=1; switch (i) { case 1; switch (i) printf ("\nFM"); case 1*2+4: printf("Radio"); } }
- FM
- FMRadio
- Radio
- Compilation error