C Puzzles
C Puzzles
1. nt main()
{
printf("%d",printf("Hi!")+printf("Bye"));
return(0);
}
(a)ByeHi!6
(b)Hi!Bye6
(c)Compile-Time Error
(d)None of these
2.
int main()
{
printf("Hi Friends"+3);
return(0);
}
(a)Hi Friends
(b)Friends
(c)Hi Friends3
(d)None of these
3.
int main()
{
printf(" F!r ") + printf(""#immers");
return(0);
}
(a)Compile-Time Error
(b)C For !immers
(c)"#n-Time Error
(d)None of these
$.
int main()
{
int %a&'(;
printf("%d %d %d %d",%a&,))%a&,++%a&,%a&)));
return(0);
}
(a)3 $ 6 %
(b)Compiler &ependant
(c)$ $ % %
(d)None of these
5.
int main()
'
printf((Hi!())
if (* ++ -,)
printf((Bye())
ret#rn(*))
-
(a)No .#tp#t
(b)Hi!
(c)Bye
(d)Hi!Bye
*.
aut! int a'(;
int main()
{
printf("%d",a);
return(0);
}
(a)Compile-Time error
(b)"#n-Time error
(c)%
(d)/npredictable
+.
int main()
{
int a,,;
f!r (a'0; a-10; a++);
f!r (,'.(; ,/0; ,)'3);
printf("%d %d",a,,);
return(0);
}
(a)Compile-Time error
(b),* 0
(c),* 1
(d)None of these
1.
int main()
{
int i'3;
f!r (i)); i-+; i'+)
printf("%d",i++);
return(0);
}
(a)No .#tp#t
(b)3$%6
(c)23$%6
(d)None of these
0.
int main()
{
printf("%d",!(100''100)+1);
return(0);
}
(a),**
(b)*
(c),
(d)2
10. 23at #i&& ,e t3e !utput !f t3e f!&&!#in4 pr!4ram 56789 : 8H9 ;"9< =6>;8 =":?ear
Friends, 23at is t3e !utput@A :
int main()
'
char line34*5) 66 7a89 len:th;4* Chars
scanf((<3=>5s(>line))
printf((?n<s(>line))
ret#rn(*))
-
(a)Compile-Time Error
(b)&ear Friends
(c)@hat is the o#tp#tA
(d)None of these
11. 23at #i&& ,e t3e !utput !f t3e f!&&!#in4 pr!4ram 56789 : 8H9 ;"9< =6>;8
=":Beans"ea 7Cean DastA :
int main()
'
char a34*5>b34*5>c34*5)
scanf((<,s <%s <3s(>a>b>c))
printf((<s <s <s(>a>b>c))
ret#rn(*))
-
(a)C . B
(b)C 7eans ea
(c)C .cean Bas
(d)None of these
int main()
'
char line34*5)
scanf((<3=,23$%6140*?n5(>line))
ret#rn(*))
-
(a)Cccepts the strin: that contains &DEDT only9
(b)Cccepts the strin: that contains &DEDT and NE@FDNE characters9
(c)Cccepts the strin: that contains anythin: other than the &DEDT and
NE@FDNE characters9
(d)None of these
uni!n E {
C3ar C3;
int i;
f&!at f;
}tempE;
int main()
{
tempE.C3'FEF;
tempE.i'+++;
tempE.f'1.3$(.1.3$(;
printf("%d",tempE.i);
return(0);
}
(a)Compile-Time Error
(b),23$%
(c)Erroneo#s o#tp#t
(d)111
?etermine #3iC3 !f t3e f!&&!#in4 are DEG=? C3araCter C!nstants. =f in%a&id, state t3e
reas!n.
(a) FyF
(,) FHrF
(C) FIF
(d) FJF
(e) FKrF
(f) F#!rdF
(4) FH0F
(3) FH@F
int main()
'
printf((<d(>siGeof(inte:er)))
ret#rn(*))
-
(a)2
(b)Compile-Time Error
(c)$
(d)None of these