0

Why the output of below c# program is 4 not 5?

int x = 16; int y = 3; x %= y*2; Console.WriteLine(x++);

15th Jul 2017, 7:27 PM
Dinesh Rajput
Dinesh Rajput - avatar
3 ответов
+ 8
third line: x = 16%6 = 4 fourth line: print x *and then* increment it by one So in effect, x=4 is printed out and after that x=5 (but is no longer printed again)
15th Jul 2017, 7:36 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 4
the output is 4, but if you want to get 5 replace x++ with ++x.
15th Jul 2017, 8:00 PM
Nomeh Uchenna Gabriel
Nomeh Uchenna Gabriel - avatar
+ 1
Dang it @Kuba, you beat me to it! Good answer by the way!
15th Jul 2017, 7:41 PM
Dillion Piazza
Dillion  Piazza - avatar