Loop Questions and Answers

Practice Mode
Showing 10 of 98 questions
Q11
Find the output void main ( ) { for putchar ('g'); putchar ('o'); putchar ('d')) putchar ('s'); }
  • A godsgodsgods...
  • B gosdgosdgosd...
  • C gosdosdosdosd...
  • D Compilation error
Answer: Option C
Q12
Find the output void main ( ) { it num = 345, m,sum=0; do { m=num%10; num=num/10; continue; sum=sum*10+m; } while (num!=0); printf ('%d", sum); }
  • A 345
  • B 543
  • C 0
  • D None of these
Answer: Option C
Q13
Find the output void main ( ) { int i,j; for (i=0, j=0; i<3, j<2: i++; j++) printf ("ok"); }
  • A ok
  • B okok
  • C Compilation error
  • D None of these
Answer: Option B
Q14
In which of the following loop/loops, he precise number of times the loop will be executed is known in advance.
  • A for loop
  • B while loop
  • C do-while loop
  • D Both b and c
Answer: Option A
Q15
Which of the following is an exit controlled loop?
  • A while
  • B do while
  • C for
  • D continue
Answer: Option A
Q16
Which of the following is an inifinite loop ? I. while (1) { } II. while (-1){ } III. while (!0)) { } IV. while ('a') { }
  • A only I
  • B I & III
  • C I & III
  • D All of the above
Answer: Option D
Q17
Which of the following is/are appropriate to give time delay usingg loop? I. for (i=1; i<100; i++) {;} II. i=1; while (i++<=100) { } III. i=1; do { } while (i++<=100);
  • A Only I
  • B II & III
  • C I & III
  • D All of the above
Answer: Option D
Q18
'repeat-until' construct of PASCAL language is same as
  • A while construct
  • B for construct
  • C do-while construct
  • D Both while and do-while construct
Answer: Option C
Q19
Find the output void main ( ) { int i, t=1, s=1; for (i=2; i<=5; i++) { t+=i; s+=t; } pritf ("%d %d", t,s,); }
  • A 10 45
  • B 15 35
  • C 10 20
  • D None of these
Answer: Option B
Q20
Find the output void main ( ) { int i=65, j=0; for (j;j<4; j++) { i+1; printf("%d", i++); } }
  • A B C D E
  • B A B C D
  • C 66 67 68 69
  • D None of these
Answer: Option B
Questions and Answers for Competitive Exams Various Entrance Test