TCS
Company
Programming
Basics
Predict the output of following code:
main()
{
if(printf(“O”, printf(“Two”))) / prints content of printf statement and takes
length of
//the string for if case execution in this case its
4, So true
printf(“Face”);
else
printf(“Focus”);
}
1. Error
2. OTwoFace
3. HaiFocus
4. Face
Read Solution (Total 5)
-
- Answer is twooface
- 6 years agoHelpfull: Yes(9) No(2)
- Error because "length of" and "4, So true" are not in comments. plus in line 2 only 1 / is there.
- 6 years agoHelpfull: Yes(4) No(4)
- Output is OTwoface
- 6 years agoHelpfull: Yes(1) No(2)
- answer is option (1) error because length of and 4,so true are in the program but not written in the comment line
- 6 years agoHelpfull: Yes(1) No(1)
- none of the options.
the output is : TwoOFace
reason:
first the inner printf executes and prints Two and returns length i.e 3->
next printf runs and prints O ,returns length 3+1=4>0 so True.Hence Face is printed - 5 years agoHelpfull: Yes(1) No(0)
TCS Other Question