This post contains 21-30 questions of c program. It will helpful to solve c aptitude questions, c quiz , c objective type questions etc in interview.
21-30 Questions
Q1:#include<stdio.h> main() { const int i=4; float j; j = ++i; printf("%d %f", i,++j); } Answer: Compiler error
Q2:
main() { int i=5,j=6,z; printf("%d",i+++j); } Answer: 11
Q3:
main() { int i =0;j=0; if(i && j++) printf("%d..%d",i++,j); printf("%d..%d,i,j); } Answer: 0..0
Q4:
int i; main(){ int t; for ( t=4;scanf("%d",&i)-t;printf("%d\n",i)) printf("%d--",t--); } // If the inputs are 0,1,2,3 find the o/p Answer: 4--0 3--1 2--2
Q5:
main(){ int a= 0;int b = 20;char x =1;char y =10; if(a,b,x,y) printf("hello"); } Answer: hello
Q6:
void main() { unsigned giveit=-1; int gotit; printf("%u ",++giveit); printf("%u \n",gotit=--giveit); } Answer: 0 65535
Q7:
main() { float me = 1.1; double you = 1.1; if(me==you) printf("I love U"); else printf("I hate U"); } Answer: I hate U
Q8:
a<<1 is equivalent to ? a) multiplying by 2 b) dividing by 2 c) adding 2 d)none of the above Answer:
Q9:
The operation of a stair case switch best explains the a) or operation b) and operation c)exclusive nor operation d)exclusive or operation Answer:
Q10:
Which of the following is/are syntactically correct? a) for(); b) for(;); c) for(,); d) for(;;); Answer: