TCS Company Programming

Predict the output of following code:
main()
{
int i=-1;
-i;
//No change in value of i
printf(“%d,%d”,i,-i);
}

1. -1, 1
2. -1, -1
3. 1, 1
4. 0, 1

Read Solution (Total 5)

TCS Other Question

What could be the output for following?
main()
{
int a= - - 2;
printf(“%d”,a);
}
1. 2
2. -2
3. 1
4. Error
Predict the output of following code:
main()
{
int var=20;
// scope of the local variable is within function or block
printf(“%d,”,var); //outer block
{
int var=30;
//Inner block
printf(“%d”,var);
}
}

1. Error
2. 20,30
3. 20,20
4. Garbage value