C-Loop Question and Answer

C-Loop Question and Answer
1. Which of the following is true about "for" loop? 
  • Any of the three experssions may be omitted
  • The openng and closing parentheses and the semicoons must be included.
  • The initial expression is evaluated only once.
  • All the above
Show Answer
2. Find the output
void main ( )
{
int x=10, y;
for (y=10; y!=x;++y)
printf ("%d", y);
printf("%d", y);
}

  • 10 11
  • 10
  • 11
  • None of these
Show Answer
3. If a loop loses its start value that loop is called as
  • Odd loop
  • Unknown loop
  • At least once
  • Infinite loop
Show Answer
4. Find the output
void main ( )
{
int i=1;
do {
printf("%d", i);
i++;
}
while (!i==5);
}

  • 1 2 3 4 5
  • 1 2 3 4 5 6
  • 1
  • None of these
Show Answer
5. Find the output
void main ( )
{
int i;
for (i=0; i<3; i++);
printf("%d", i*i);
printf ("strange");
}

  • 9strange
  • 014strange
  • strange
  • Compilation error
Show Answer
6. Find the output
void main ( )
{
int i;
for (i=0; i<3; i++);
printf("%d", i*i);
printf ("strange");
}

  • 9strange
  • 014strange
  • strange
  • Compilation error
Show Answer
7. 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++;
}
}

  • 23454556
  • 2345
  • Compilation error
  • None of these
Show Answer
8. Find the output
void main ( )
{
int i=1;
while (!i=5)
{
printf ("%d", i);
i++;
}
}

  • 1
  • 12345
  • 1234
  • Compilation error
Show Answer
9. Find the output
void main ( )
{
for (putchar ('g'), i); putchar ('o'putchar ('d'))
putchar ('s');
}

  • godsgodsgods...
  • gosdgosdgosd...
  • gosdosdosdosd...
  • Compilation error
Show Answer
10. Find the output
void main ( )
{
char m[ ]={"hello world"}'
int n;
for (c=sizeof(m); m; putch(m)[-n]));
}

  • d1row olleh
  • hello world
  • dddddddddd.....
  • infinite loop
Show Answer
Questions and Answers for Competitive Exams Various Entrance Test