C Language MCQ’S | Control Instructions 6

26.
What will be the output of the program?

#include<stdio.h>
int main()
{
char str[]=”C-program”;
int a = 5;
printf(a >10?”Ps\n”:”%s\n”, str);
return 0;
}

A. C-program
B. Ps
C. Error
D. None of above


27.
Point out the error, if any in the for loop.

#include<stdio.h>
int main()
{
int i=1;
for(;;)
{
printf(“%d\n”, i++);
if(i>10)
break;
}
return 0;
}

A. There should be a condition in the for loop
B. The two semicolons should be dropped
C. The for loop should be replaced with while loop.
D. No error


28.
Point out the error, if any in the program.

#include<stdio.h>
int main()
{
int a = 10;
switch(a)
{
}
printf(“This is c program.”);
return 0;
}

A. Error: No case statement specified
B. Error: No default specified
C. No Error
D. Error: infinite loop occurs


29.
Point out the error, if any in the program.

#include<stdio.h>
int main()
{
int i = 1;
switch(i)
{
printf(“This is c program.”);
case 1:
printf(“Case1”);
break;
case 2:
printf(“Case2”);
break;
}
return 0;
}

A. Error: No default specified
B. Error: Invalid printf statement after switch statement
C. No Error and prints “Case1”
D. None of above


30.
Point out the error, if any in the while loop.

#include<stdio.h>
int main()
{
int i=1;
while()
{
printf(“%d\n”, i++);
if(i>10)
break;
}
return 0;
}

A. There should be a condition in the while loop
B. There should be at least a semicolon in the while
C. The while loop should be replaced with for loop.
D. No error


Visitor Counter

0051042