TCS Company Programming

Predict the output of following code:
main()
{
int i=10,j=2,k=0,m;
m=++i&&++j&&++k; // m = 11 && 3 && 1 = 1
printf(“%d%d%d%d”,i,j,k,m);
}
1.11,3,1,1
2. 11,2,0,1
3. 11,3,1,0
4. 10,2,0,1

Read Solution (Total 4)

TCS Other Question

Predict the output of following code:
main()
{
int a=10,x=20;a=a++ + 10; // a = 10+10 first a is increment to 11 but
overwritten by 20
x=x++ + ++a; // x = 20 + 21 a is incremented first from 20 to 21
printf(“%d,%d”,a,x);
}
1. 22,43
2. 12,21
3. 10,20
4. 42,42
Predict the output of following code:
main()
{
int i=10;
printf(“%d,%d”,++i,++i);
}
1. 11,12
2. 12,11
3. 10,11
4. 11,10