Answer the Question
int a,b;
a=-3--3;
b=-3--(-3);
printf("a=%d b=%d",a,b);
what is the values of a and b
By :
Naresh Dwivedi On :
19-Feb-2012 Answers :
2
Report Abuse
Previous Answers
0
On :
17-Mar-2012 Accept Count
:
0
a=-3+3=0
b=-3-3=6....k i'll tell u few htings abt unary operators
As unary operations have only one operand they are evaluated before other operations containing them. Here is an example using negation:
3 - -2
Here the first '-' represents the binary subtraction operation, while the second '-' represents the unary negation of the 2. Therefore, the expression is equal to:
3 - (-2) = 5
Technically there is also a unary positive but it is not needed since we assume a value to be positive:
(+2) = 2
Unary positive does not change the sign of a negative operation:
(+(-2)) = (-2)
In this case a unary negative is needed to change the sign:
(-(-2)) = (+2)
On :
21-Feb-2012 Accept Count
:
1