+ 1
Why the output of this code is 9 not 10? Plz explain đ
#include <iostream> using namespace std; int main() { int a=9; { int a=9; a++; } cout<<a++; return 0; }
3 Answers
+ 3
scope. The second a belongs to a inner block code and a++ increments the a in its scope
+ 1
Arturop Got it
Thanks for explaining đ
0
Because you use post-increment operator when you send output of <a>. Had you used pre-increment operator, you'll get 10
cout << ++a; // output 10