Plz tell me why the output is 16 ? I thought it would be 12 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Plz tell me why the output is 16 ? I thought it would be 12

#include <iostream> using namespace std; int main() { int a=2; int b=++a; int c=++b; a=b*c; cout<<a; return 0; } Plz explain 🙏

5th Oct 2021, 3:41 AM
Jainil Raval
Jainil Raval - avatar
2 Answers
+ 4
#include <iostream> using namespace std; int main() { int a=2; int b=++a; //b=3, a=3 int c=++b; //c=4, b=4 a=b*c;// a=4*4=16 cout<<a; return 0; }
5th Oct 2021, 3:51 AM
Arun Ruban SJ
Arun Ruban SJ - avatar
+ 2
Arun Ruban SJ Ok... Got it 👍 Thanks for explaining
5th Oct 2021, 3:57 AM
Jainil Raval
Jainil Raval - avatar