Control Structure Questions and Answers

Practice Mode
Showing 10 of 97 questions
Q11
Find the output void main ( ) char x='A'; switch (x) { if (x==A) { printf("tomtom"); } else { printf("tom") default:printf("harry"); } } }
  • A tomtom
  • B harry
  • C tomharry
  • D Compilation error
Answer: Option D
Q12
Find the output void main ( ) { if (printf("hello"); else printf ("hai"); }
  • A hello
  • B hai
  • C Compilation error
  • D None of these
Answer: Option A
Q13
Find the output void main ( ) { switch (2) { case 2: printf("no"); continue; case 1: printf("output"); default : printf ("continue"); }
  • A no
  • B nononono....
  • C nooutputcontinue
  • D None of these
Answer: Option D
Q14
Which of the following is/are true for nested if I. It can only test for equality. II. Conditions may be repeatred for number of times. III. it can evaluate relational or logical expressions. IV. Character constants are automatically converted to integers.
  • A I & II
  • B I. II & III
  • C II, III & IV
  • D All o the above
Answer: Option C
Q15
Find the output. void main ( ) { int i=2; i++; if (i=4) printf("i=4"); else printf("i=3"); }
  • A i=3
  • B i=4
  • C Garbage value
  • D None of these
Answer: Option B
Q16
Find the output void main ( ) { int x, y; printf("%d", x=(y=5, y*y)); }
  • A 5
  • B 25
  • C Invalid expressio
  • D Compilation error
Answer: Option B
Q17
Find the output void main ( ) { char a='H'; switch (a) { case 'H': printf("%c", 'H'); case 'E": printf("%c", 'E'); case 'L': printf("%c", 'L')} case 'O': printf ("%c", 'O'); } }
  • A HELLO
  • B HEL
  • C HELO
  • D Compilation error
Answer: Option D
Q18
Which of the following is true about the switch statement ?
  • A The default statement is necessary
  • B The break statement is compulsory
  • C The statements associated with a case do not form a block
  • D Switch without case is worthless
Answer: Option D
Q19
Find the output void main ( ) { int x=1, y=2, z=3, result; result=(x+1?y>=2?z>3?1:2:3:4); printf("%d",result); }
  • A 1
  • B 2
  • C 3
  • D 4
Answer: Option B
Q20
Find the output void main ( ) { it (6>3) { printf("hello"); break; } else printf("bye"); }
  • A hello
  • B bye
  • C Compilation error
  • D None of these
Answer: Option C
Questions and Answers for Competitive Exams Various Entrance Test