+ 1

Please heeeeelp

X=2 , y=4 Y*=2 X=y++ - ++y X++ Printf(x and y) What is x and y!!!?

23rd Apr 2018, 9:38 PM
Nour Salh
Nour Salh - avatar
10 Answers
+ 2
Actually: x = undefined, y = 6, C is case-sensitive. That means X is not x. Y is not y. ^Kidding, but be careful all the same when posting code. PS: printf("%d\n%d\n", x, y); is what you're looking for. Ace Aren't mathematics pre-calculated and converted to literals where relevant values are known at compile-time by all compilers? Just curiosity, I'd still never rely on that behaviour.
23rd Apr 2018, 11:27 PM
non
+ 2
the first y++, means use the value of y, and THEN increment it by 1. ++y means increment it by 1, and THEN use it. y=8 just before the x=y++ - ++y line. That line with the y++ etc, therefore is really this: x = value of y (but then increment y by 1) - (increment y by 1) value of y x = 8 - 10 [and now y is 2 higher]
23rd Apr 2018, 9:58 PM
Emma
+ 2
nonzyro Definitely agree. That's why I said "if ignoring compilation errors" â˜ș It's almost doable as some kind of C pseudo-code đŸ€•đŸ™ƒ
23rd Apr 2018, 11:30 PM
Emma
+ 2
Xan Actually it reminds me of a Natural Language dialect of Basic a friend proposed for teaching kids to program. I said stick to Lego.
24th Apr 2018, 8:37 AM
non
+ 1
X=2 , y=4 Y*=2 // y=8 X=y++ - ++y // X=-2, y=10 X++ // X=-1 Printf(x and y) What is x and y!!!? x=-1 y=10 If ignoring compilation errors!
23rd Apr 2018, 9:47 PM
Emma
+ 1
I need to Know something when i delete x++ then x=-2 hoow
23rd Apr 2018, 9:52 PM
Nour Salh
Nour Salh - avatar
0
Thhhhhhhanks so freaking much
23rd Apr 2018, 10:09 PM
Nour Salh
Nour Salh - avatar
0
Yes I know this .. just it's the keyboard phone
23rd Apr 2018, 11:32 PM
Nour Salh
Nour Salh - avatar