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)

TCS Other Question

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
Predict the output of following code:
main()
{
int a=100,b=300;
if(a>50)
// No braces, so only one immediate statement is part of if
a=200​ ;
b=400;
printf(“%d”,b);
}

1. 400
2. 300
3. 100
4. Error