C Interview Questions 11-20

This post contains 11-20 questions of c program. It will helpful to solve c aptitude questions, c quiz , c objective type questions etc in interview.

11-20 Questions

Q1:

void main()
{
int i=5;
printf("%d",i+++++i);
}
Answer:
Compiler Error

Q2:

#include<stdio.h>
main()
{
int i=1,j=2;
switch(i)
{
case 1: printf("GOOD");
break;
case j: printf("BAD");
break;
}
}
Answer:
Compiler Error: Constant expression required in function main.

Q3:

main()
{
int i;
printf("%d",scanf("%d",&i)); // value 10 is given as input here
}
Answer:
1

Q4:

main()
{
int i=0;
for(;i++;printf("%d",i)) ;
printf("%d",i);
}
Answer:

Q5:

main()
{
printf("%d", out);
}
int out=100;
Answer:
Compiler error: undefined symbol out in function main.

Q6:

main()
{
int i=-1;
+i;
printf("i = %d, +i = %d \n",i,+i);
}
Answer:
i = -1, +i = -1

Q7:

main()
{
char not;
not=!2;
printf("%d",not);
}
Answer:
0

Q8:

main()
{
int k=1;
printf("%d==1 is ""%s",k,k==1?"TRUE":"FALSE");
}
Answer:
1==1 is TRUE

Q9:

main()
{
int y;
scanf("%d",&y); // input given is 2000
if( (y%4==0 && y%100 != 0) || y%100 == 0 )
printf("%d is a leap year");
else
printf("%d is not a leap year");
}
Answer:
2000 is a leap year

Q10:

main()
{
int i=-1;
-i;
printf("i = %d, -i = %d \n",i,-i);
}
Answer:
i = -1, -i = 1