TCS Company Programming Output

Predict the output of following code:
main()
{
int a=10,x;
x= a-- + ++a;
printf(“%d”,x);
}
1. 19 ​
2. 20​
3. 22
4. 23

Read Solution (Total 6)

TCS Other Question

Predict the output of following code:
main()
{
int x,a=10;
x=9*5+​ 7/3​ -6+a; ​ //45+2-6+10 = 51 ​ // 7/3 =2 int division
printf(“%d”,x);
}
1. 51
2. 51.5
3. 31
4. None of these
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