0
Why is the output of this code 6? I feel like it should give a error .
4 Answers
+ 4
a = 8
b = ++a, so both a and b are 9 now
if (a>5) is true
b -= 3 which is 9-3=6
So else is not executed and value of b is printed to the console.
+ 2
If the c for console is lowercase, then yes it will give an error. Otherwise, 6 is the correct output.
b is set to ++a which is 9
a > 5 is true so b -= 3 is ran. Now b = 6 which is then output.
0
int a = 8;
int b = ++a;
if (a > 5)
b -= 3;
else
b = 9;
console.WriteLine(b);
0
I see, thanks this dose answer some questions