MCQ - Structure And Loops in C Programming
21. What is the output of this program?
#include <stdio.h>
int main()
{
int a = 5;
if (a == 6); a = 0;
if (a == 5)
a++;
else a += 2;
printf("%d", a);
return 0;
}
View Answer
22. What is the output of this program?
#include <stdio.h>
int main()
{
int a = 1, b = 0;
int c = (a++, b++) ? b : a;
printf("%d", c);
return 0;
}
View Answer
23. What is the output of this program?
int main()
{
int a = 1, b = 0;
int c = a%2 ? a++ : a-- ? a=0 : ++b ? b = 2 : b++ ;
printf("%d", c);
return 0;
}
View Answer
24. What will be the output of the program in 16 bit platform ?
#include <stdio.h>
int main()
{
int a=2, b=1, c=2;
switch(a)
{
case b:
printf("You are in b ");
break;
case c:
printf("You are in c ");
break;
default:printf("You are in default");
}
return 0;
}
View Answer
25. What will be output when you will execute following c code?
#include <stdio.h>
int main()
{
int a=2;
switch(a,a+1)
{
case 2:
printf("You are in b ");
break;
case 3:
printf("You are in c ");
break;
default:
printf("You are in default");
}
return 0;
}
View Answer
26. What is the output of this program?
#include <stdio.h>
void main() {
float a = 0.7;
if ( a < 0.7 )
printf( "Yes" );
else
printf( "No" );
}
View Answer
27. What is the output of this program?
#include <stdio.h>
void main()
{ char a=0;
for(a=0;a<=127;a++)
{
printf("%d ",a);
}
}
View Answer
28. How many times the loop will execute ?
for(int i = 0 ; i < 10 ; i++)
{
i = i*2;
i--;
}
View Answer
29. What is the output of this program?
#include <stdio.h>
void main()
{
int j = -5;
for(;j;printf("%d ", j++));
}
View Answer
30. What is the output of this program?
void main()
{
int x=0;
for(;;)
{
if(x==3)
break;
printf("%d ",++x);
}
}
View Answer
Also check :