0

C++ challenge Question

#include <iostream> using namespace std; int main() { int x = 4; int y = 3; if((++x>6)&&(y>2)) cout<<y; if((x++>5)&&(y>1)) cout<<x; if((x>5)&&(y>2)) cout<<x; return 0; } //Output is : 6 -> but how?

13th Jul 2018, 11:49 AM
Ankit
Ankit - avatar
1 Réponse
+ 4
++x>6 && y>2 x is 5 now 5>6 && 3>2 = False && True = False x++>5 && y>1 x is still 5 5>5 && 3>1 = False && True = False x>5 && y>2 x is now 6 6>5 && 3>2 = True && True = True
13th Jul 2018, 12:02 PM
Mert Yazıcı
Mert Yazıcı - avatar