+ 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 ответов
+ 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