0

#include <iostream> using namespace std; int main() { int x=2; cout <<(x-++--x); return 1; }

I don't understand this.

25th Sep 2016, 12:40 PM
Sourabh Goyal
Sourabh Goyal - avatar
4 Antworten
+ 2
It's like + and + is + + and - is - - and + is - - and - is +... x-+ +--x =x-+ --x =x-- -x =x+-x =x-x=0
25th Sep 2016, 3:06 PM
Soutik
Soutik - avatar
+ 1
I am not sure but I think it's an error.
14th Nov 2016, 5:07 AM
Karan Jain
Karan Jain - avatar
- 1
The operators cancel eachother out: x-++--x x-+--x x---x x+-x x-x Therefore output is 0.
25th Sep 2016, 12:56 PM
Cohen Creber
Cohen Creber - avatar
- 1
it follows multiplication rule like +*+ = + +*- = - -*- = + here finally you get - so x-x = 0
25th Sep 2016, 6:33 PM
Shivam Raghuwanshi