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); }
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,
+ 2
I done it now.
+ 1
Your right sorry it is C*