TCS Company Programming Basics

Predict the output of following code:
main()
{
if( printf(“Hai”)) // 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. HaiFace
3. HaiFocus
4. Face

Read Solution (Total 4)

TCS Other Question

Predict the output of following code:
main()
{
if(5,4,3,2,1,0,8,​ 9 ​ ) // Last value of list is considered
printf(“True”);
else
printf(“False”);
}

1. True
2. False
3. True False
4. Error
Predict the output of following code:
main()
{
if( printf(“”)) // prints content of printf statement and
//takes length of the string for if case
case its 1, So true
printf(“Face”);
else
printf(“Focus”);
}

1. Error
2. Face
3. “”Focus
4. Face