TCS
Company
Programming
Output
What could be the output for following?
main()
{
int a= - - 2;
printf(ā%dā,a);
}
1. 2
2. -2
3. 1
4. Error
Read Solution (Total 11)
-
- ans 4.Error
error: lvalue required as decrement operand - 6 years agoHelpfull: Yes(6) No(0)
- Correct answer will be 2 becoz - -2 will be 2 due to multiplication of two -ve * -ve = +
- 6 years agoHelpfull: Yes(3) No(5)
- 1 because predecrement operator decrement the given value and then displays it
- 6 years agoHelpfull: Yes(2) No(2)
- Error
Increment and decrement operator works with variable - 6 years agoHelpfull: Yes(2) No(0)
- the answer is 2
- 6 years agoHelpfull: Yes(1) No(0)
- I agree with all the answers that error will be the correct answer but can anyone explain what is the logic behind?
- 6 years agoHelpfull: Yes(0) No(0)
- the ans is 2
- 6 years agoHelpfull: Yes(0) No(0)
- I have already tried running this program on IDE and this gives an error.
- 6 years agoHelpfull: Yes(0) No(0)
- ans :: will be error always.... coz 2 is a constant and u cannot modify a constant value...
if u try to chnage a constant value then how can we say that its a constant :P - 6 years agoHelpfull: Yes(0) No(0)
- Answer is option 1
- 5 years agoHelpfull: Yes(0) No(0)
- ans is 2.
If any varilable delared directly that will print - 5 years agoHelpfull: Yes(0) No(0)
TCS Other Question