0
Please tell why the answer is 101 ?
gave an string 3+2 and expected the answer 1 https://code.sololearn.com/c1oeyte23cGo/?ref=app
2 ответов
+ 2
note is a string.
note[0] returns a character.
The ascii value for the character '3' is 51 and the ascii value for '2' is 50.
50 + 51 = 101.
You should subtract the character '0' ( which has a value of 48 ) from both characters like this:
cout << note[0] - '0' + note[2] - '0';
0
thanku very much