0
please explain output
Hi #include <iostream> using namespace std; int main() { int x = 8; do { cout << x; }while(!-2); while(0); return 0; } I am getting output as 8....How? Specially what is syntax of !-2 in while loop.
1 Answer
+ 3
Ketan Lalcheta
Do while loop execute atleast once so output is 8
!-2 is not a syntax, as like !true and !false it's !-2
here !-2 returns 0
so it's
do {
cout << x;
} while (0);