+ 2

Why the inserted code give a pattern?

https://code.sololearn.com/csI3VZDfm2X4/?ref=app why the output is like a pattern?

8th Apr 2018, 2:50 PM
ajbura
ajbura - avatar
2 odpowiedzi
+ 1
I have changed your code a little and it gives the same result https://code.sololearn.com/cpJtrKaqaEUA/?ref=app
8th Apr 2018, 3:04 PM
Sundeep Chand
Sundeep Chand - avatar
0
A variable of char type can hold only 1 byte of data. So when you are assigning a string to it only the last character of the string is retained. So a = 'c' and b='z' When you add them you are actually adding their ASCII values and thus you are assigning 99+122=221 to a. When c is printed the corresponding ASCII character is displayed.
8th Apr 2018, 3:13 PM
Sundeep Chand
Sundeep Chand - avatar