0

Why in the prefix and postfix we write: Console.WriteLine(x+" "+y); ?

this is the program: int x=4; int y=x++; Console.WriteLine(x+" "+y); output: 5 4

16th Mar 2018, 6:37 PM
Majdy R
Majdy R - avatar
3 Answers
+ 3
the initial value of x is 4. y=x++ means "assign the value of x to y and AFTER THAT increase the value of x by 1". so the value of y is 4 and the new value of x is 5. the WriteLine says: write x then a blank space and then write y.
16th Mar 2018, 6:46 PM
storm
storm - avatar
0
I understand this but why said (x+ +y) not(x+ y+)?
16th Mar 2018, 6:49 PM
Majdy R
Majdy R - avatar