Why this code prints 'A'? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
7th Aug 2018, 4:15 AM
Pulsara Sandeepa
Pulsara Sandeepa - avatar
2 Answers
+ 1
Char stores the unicode value of a character, in this situation x='B'=66 ; char y='b' = 98 ; char z='a'=97; you do z+=x-y which is equivalent to z = z+(x-y). Substitute values in and you get z =97+(66-98) which simplifies to z = 97 - 32 which equals z = 65 which is the unicode char value for 'A'
7th Aug 2018, 5:28 AM
JME
0
thank you very much...great expalin...💪💪
7th Aug 2018, 5:56 AM
Pulsara Sandeepa
Pulsara Sandeepa - avatar