TCS Company Programming Basics

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

Read Solution (Total 7)

TCS Other Question

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
Predict the output of following code:
main()
{
int a=2;
if(a-- , --a, a) // if(2, 0, 0) last value 0 →False
printf(“Tom”);
else
printf(“Jerry”);
}

1. Tom
2. Jerry
3. Tom Jerry
4. Error