TCS
Company
Programming
Program
What is the output of:
main( )
{
int a, b ;
a = -3 - - 3 ;
b = -3 - - ( - 3 ) ;
printf ( "a = %d b = %d", a, b ) ;
}
Read Solution (Total 16)
-
- Output : a = 0, b = -6
Usual arithmetic operation...
- 10 years agoHelpfull: Yes(18) No(3)
- same precedence operator will execute from right to left.
- 10 years agoHelpfull: Yes(4) No(3)
- a=0 b=-6
Use arithmetic ooeration
a= -3 + 3
a=0
b= -3 - (+3)
b= -3-3
b=-6
- 10 years agoHelpfull: Yes(3) No(2)
- error, Lvalue required
- 10 years agoHelpfull: Yes(3) No(2)
- Error
We can not do increment and decrement operations on constant values.
- 9 years agoHelpfull: Yes(2) No(1)
- error,call to undefined function printf
- 10 years agoHelpfull: Yes(1) No(2)
- A=0 B=-6 IS ANSWER
- 10 years agoHelpfull: Yes(0) No(3)
- a=0 b=-6 is the answer
- 10 years agoHelpfull: Yes(0) No(0)
- a=0 b=-6
since a=-3+3=0
and b=-3+(-3)=-6 - 10 years agoHelpfull: Yes(0) No(0)
- 0 -6
a=-3+3;
b=-3-3 - 10 years agoHelpfull: Yes(0) No(0)
- output; a=0 b=-6
- 9 years agoHelpfull: Yes(0) No(0)
- decrement and increment operator are right to left precedence so
-3-4=-7
second one is also -7 - 9 years agoHelpfull: Yes(0) No(1)
- ans) error
L VALUE REQUIRED
- 9 years agoHelpfull: Yes(0) No(0)
- -6 and 0..becoz -3--3 gives -6
- 7 years agoHelpfull: Yes(0) No(0)
- a = -3 - - 3 =-3+3=0
b = -3 - - ( - 3 )=-3-+3=-3-3=-6 - 6 years agoHelpfull: Yes(0) No(0)
- a = 0 b = -6
- 6 years agoHelpfull: Yes(0) No(0)
TCS Other Question