![]() |
c input/output
#include<stdio.h>
#include<conio.h> int main(){ int a,b; a = -3- -3; b = -3 - - (-3 ); printf("%d %d",a,b); getch(); return 0 ; } the ouput is -6 and 0.Please explain how? |
Re: c input/output
Compiler bug probably. (-3) - (-3)=0 because any finite number minus itself is zero, so if your compiler thinks this is -6 then it's wrong. Similarly (-3) - -(-3) = (-3) - (3) = -6, not 0.
The answers are correct though, if transposed, so if the output is 0 -6 then that's correct. -6 0 would be wrong. To make certain, split the output with more detail to be sure: Code:
printf("(-3) - (-3) = %d\n",a);Code:
void test49()Code:
0 -6 |
Re: c input/output
Sorry i mistyped the answer.Thank you for replying.
|
| All times are GMT +5.5. The time now is 09:24. |