0

Can anyone explain to me why this isn't 4?

int a = 4; int b = ++a; if(b > 5) { Console.WriteLine(b); } else { Console.WriteLine(a); }

9th Apr 2019, 8:10 AM
Emma
3 Answers
+ 6
int a = 4; int b = ++a; // b = 5 // b is not greater than 5 // execution flow goes to // else block if(b > 5) { Console.WriteLine(b); } else { Console.WriteLine(a); } P.S. Are you sure that was C++? the `Console.WriteLine` got me thinking you were actually referring C#. Emma Kindly edit the Relevant Tags to C# rather than C++. Thanks,
9th Apr 2019, 8:22 AM
Ipang
+ 2
I done it now.
9th Apr 2019, 8:28 AM
Emma
+ 1
Your right sorry it is C*
9th Apr 2019, 8:23 AM
Emma