C-Loop Question and Answer
C-Loop Question and Answer
41. Find the output
void main ( )
{
int i;
while (i=strrcmp ("cite", "cite\0"));
}
void main ( )
{
int i;
while (i=strrcmp ("cite", "cite\0"));
}
- 0
- 1
- 11111....
- None of these
42. Find the output
void main ( )
{
int i;
for (i=3; i<15; i+=3);
printf("%d", i);
}
void main ( )
{
int i;
for (i=3; i<15; i+=3);
printf("%d", i);
}
- 3 6 9 12
- 3 3 3 3
- 15
- 12
43. In a for loop if the condition is missing then.
- it is assumed to be present and taken to be true.
- it is assumed to be present and taken to be false
- It results in a syntax error
- Execution will be terminated abrupty.
44. Find the output.
void main ( )
{
int i, j;
for (i=3; i>=1;j--)
for (j=i;j>=1' j--)
printf ("%d", i);
}
void main ( )
{
int i, j;
for (i=3; i>=1;j--)
for (j=i;j>=1' j--)
printf ("%d", i);
}
- 321211
- 333221
- 332211
- 123233
45. Find the output
void main ( )
{
int i=5. c=0;
do
{
i--;
c++;
}
whie (i==0);
printf('%d', c);
}
void main ( )
{
int i=5. c=0;
do
{
i--;
c++;
}
whie (i==0);
printf('%d', c);
}
- 3
- 4
- 1
- None of these
46. Find the correct output.
void main ( )
{
while (99)
{
if (printf("%d", printf ('%d")))
break;
else
continue;
}
}
void main ( )
{
while (99)
{
if (printf("%d", printf ('%d")))
break;
else
continue;
}
}
- 0 1
- 0 0
- Infinite loop
- None of these
47. How many times the loop will be executed ?
void main ( )
{
int i=0;
for (;i++;)
printf ("%d", i);
}
void main ( )
{
int i=0;
for (;i++;)
printf ("%d", i);
}
- Infinite times
- 32767
- 0
- The maximum integer value for a particular machine
48. How many times a for loop will exeuted in this program ?
void main ( )
{
char ch;
for (ch=0; ch<128; ch+4)
printf('%d", ch);
}
void main ( )
{
char ch;
for (ch=0; ch<128; ch+4)
printf('%d", ch);
}
- 127 times
- 64 times
- 32 times
- Infinite times
49. Find the output
void main ( )
int x=0;
for (;;)
{
if (++x==6)
break;
continue;
}
printf('X=%d", x);
}
void main ( )
int x=0;
for (;;)
{
if (++x==6)
break;
continue;
}
printf('X=%d", x);
}
- X=5
- X=6
- X=7
- Unpredictable output