+ 5
Can anyone tell me how the output of this code is 55?
INT main() { INT x=3; char y='4'; cout<<x+y; return 0; }
4 Answers
+ 2
I can. I am guessing you did this on purpose, but maybe not.
the char 4 stores an int value of 52. normally if you were to cout the char 4 it would print 4, because that is how it handles the char value. Because you are adding it to an int it is adding the value of 52 and not the ascii representation of 52 which is 4
I like that problem
+ 2
The ASCII code of char '4' is 52 (x34). The expression x+y convert char to int, so the result is 55.
Hope this helpful. đ
+ 1
I didn't get you
what's that 52
from where did that come
+ 1
WA thanks