C-Loop Question and Answer
C-Loop Question and Answer
31. State the correct statement.
- a for loop may be nested in a while loop.
- A d-while loop may be nested in a for loop
- A while loop may be nested in a for loop
- All the above
32. Find the output
void main ( )
{
int i=32767u, x=49;
while (i>3)
{
printf("%c', x);
i++;
}
}
void main ( )
{
int i=32767u, x=49;
while (i>3)
{
printf("%c', x);
i++;
}
}
- 1
- 1111
- 1111.....
- Compilation error
33. Find the output
void main ( )
{
int x=5;
for (;x<=5; if (x==5))
printf("%d', ++x);
}
void main ( )
{
int x=5;
for (;x<=5; if (x==5))
printf("%d', ++x);
}
- 5
- 6
- Compilation error
- No output
34. Find the output.
void main ( )
{
int signed i=1;
do
{
printf ("%d", i);
}
while (i--);
}
void main ( )
{
int signed i=1;
do
{
printf ("%d", i);
}
while (i--);
}
- 1
- Infinte loop
- 10
- None of these
35. Find the output.
void main ( )
{
int i=1;
while (i<=2)
{
printf("%d\i",i);
}
}
void main ( )
{
int i=1;
while (i<=2)
{
printf("%d\i",i);
}
}
- %i%i
- 1 2
- % %
- Compilation error
36. Find the output
void main ( )
{
while (!" ")
{
printf ("Helo");
}
}
void main ( )
{
while (!" ")
{
printf ("Helo");
}
}
- Prints Hello infinite times
- Hello
- No output
- Compilation error
37. Find the output.
void main ( )
{
int x=3;
float y=1;
while (x!=y)
{
x--;
y++;
if(x==y)
printf ("%d %d", x, y);
}
}
void main ( )
{
int x=3;
float y=1;
while (x!=y)
{
x--;
y++;
if(x==y)
printf ("%d %d", x, y);
}
}
- 2 3
- 2 suffering
- 2 2
- Compilation error
38. Find the output.
void main ( )
{
int i;
for (i=0;i++<=5;
printf ("5u", i);
}
void main ( )
{
int i;
for (i=0;i++<=5;
printf ("5u", i);
}
- 6
- 7
- Compilation error
39. Find the output
static int i;
void main ( )
{
for (; ~i ; i--)
printf ("%d', i);
}
static int i;
void main ( )
{
for (; ~i ; i--)
printf ("%d', i);
}
- 0 -1 -2 3
- 0
- 0 -1 0 -1
- none of these
40. Fint the output.
void main ( )
unsigned int i=5;
while (i-->=0)
printf ("5d", i);
}
void main ( )
unsigned int i=5;
while (i-->=0)
printf ("5d", i);
}
- 12345
- Ivalue required
- Infinite loop
- None of these