TCS Company Programming Technical

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

Read Solution (Total 3)

TCS Other Question

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
Which among the following operator
has the right to left associativity?
1. Arithmetic
2. logical
3. Relational
4. Increment/Decrement