Loop Questions and Answers

Practice Mode
Showing 10 of 98 questions
Q1
Which of the following is true about "for" loop? 
  • A Any of the three experssions may be omitted
  • B The openng and closing parentheses and the semicoons must be included.
  • C The initial expression is evaluated only once.
  • D All the above
Answer: Option D
Q2
Find the output void main ( ) { int x=10, y; for (y=10; y!=x;++y) printf ("%d", y); printf("%d", y); }
  • A 10 11
  • B 10
  • C 11
  • D None of these
Answer: Option B
Q3
If a loop loses its start value that loop is called as
  • A Odd loop
  • B Unknown loop
  • C At least once
  • D Infinite loop
Answer: Option A
Q4
Find the output void main ( ) { int i=1; do { printf("%d", i); i++; } while (!i==5); }
  • A 1 2 3 4 5
  • B 1 2 3 4 5 6
  • C 1
  • D None of these
Answer: Option C
Q5
Find the output void main ( ) { int i; for (i=0; i<3; i++); printf("%d", i*i); printf ("strange"); }
  • A 9strange
  • B 014strange
  • C strange
  • D Compilation error
Answer: Option A
Q6
Find the output void main ( ) { int i; for (i=0; i<3; i++); printf("%d", i*i); printf ("strange"); }
  • A 9strange
  • B 014strange
  • C strange
  • D Compilation error
Answer: Option A
Q7
Find the output void main ( ) { int i, j=1; for (i=1; i<5; i++) while (j<5) { printf ("%d', i+j); if(i==2&& j==2) break; j++; } }
  • A 23454556
  • B 2345
  • C Compilation error
  • D None of these
Answer: Option B
Q8
Find the output void main ( ) { int i=1; while (!i=5) { printf ("%d", i); i++; } }
  • A 1
  • B 12345
  • C 1234
  • D Compilation error
Answer: Option D
Q9
Find the output void main ( ) { for (putchar ('g'), i); putchar ('o'putchar ('d')) putchar ('s'); }
  • A godsgodsgods...
  • B gosdgosdgosd...
  • C gosdosdosdosd...
  • D Compilation error
Answer: Option C
Q10
Find the output void main ( ) { char m[ ]={"hello world"}' int n; for (c=sizeof(m); m; putch(m)[-n])); }
  • A d1row olleh
  • B hello world
  • C dddddddddd.....
  • D infinite loop
Answer: Option D
Questions and Answers for Competitive Exams Various Entrance Test