Loop Questions and Answers

Practice Mode
Showing 10 of 98 questions
Q71
Find the output void main ( ) { int I; for (I=o; i<20; I++) { switch (I) { case 0; I +=5; cse 1 : I +=2; case 5 : I += 5; default : I +=4; } printf ("%d", I); } }
  • A 0, 5, 9, 13,13
  • B 5, 9, 13, 17,
  • C 12, 17, 22,
  • D 16, 21,
Answer: Option D
Q72
Find the ouptu void main ( ) { static int b; for (;b<5;b++) { printf("hello"); main ( ); } }
  • A hello will display 5 times
  • B hello will display unknown times
  • C Infinite loop
  • D Compilation error
Answer: Option B
Q73
Find the output void main ( ) { char str[20]; static int i; for (;;) { i++[str]='a'+15; if (i==19) break; } i [str]='\0'; printf ("%s", str); }
  • A P
  • B Garbage value
  • C Compilation error
  • D PPPPPPPPPPPPPPPPPPPP
Answer: Option A
Q74
Find the output. void main ( ) { unsigned int a=-1; static int count; while (a) { count++; a&a-1; } prrintf('5d", count); }
  • A 0
  • B 1
  • C 16
  • D None of these
Answer: Option C
Q75
Find the output void main ( ) { char a[10]={1, 2, 3, 4, 8, 6}; int x; for (x=0; x<4; x++) a[x]=x+'a'; printf("%s", a[x]); }
  • A 123456
  • B 56
  • C 86
  • D Garbage
Answer: Option D
Q76
Find the output. void main ( ) { int i=5, j=2; do { printf('%d", i--); } while (j==(float) printf("%d", 12)); }
  • A 5
  • B 54321
  • C Compilation error
  • D Infinite loop
Answer: Option D
Q77
Find the output. void main ( ) { int i=3; for (i--; i<7; exit (0)) printf("%d", i++); }
  • A No output
  • B 2
  • C 23456
  • D None of these
Answer: Option B
Q78
Find the output. void main ( ) { int i=9; for (i--; i--; i--) printf("%d"", i); }
  • A 9 6 3
  • B 7 5 3 1
  • C Compiltion error.
  • D Infinite Loop
Answer: Option A
Q79
Find the output. void main ( ) { int i; for (i=1; i<5; i++) { if (i<3) continue; else break; printf("5d', i); } printf('5d", i); }
  • A 23
  • B 33
  • C 3
  • D No output
Answer: Option C
Q80
Find the output void main ( ) { int a=0; for (a; ++a; a<=100) printf('5d',a); }
  • A Print 1 to 100
  • B Print 1 to 100 infinite times
  • C Print 1 to -32768
  • D Infinite loop
Answer: Option C
Questions and Answers for Competitive Exams Various Entrance Test