+ 2
Convert string to int
Why it output 50? #include <iostream> using namespace std; int main() { cout << '2' + '2' - '2'; return 0; } // output: 50
3 Respostas
+ 12
In this case, the ASCII value of characters were involved in the addition and subtraction operations.
http://www.asciitable.com/mobile/
The character '2' has an ASCII value of 50.
50+50-50 is 50.
+ 7
That is not a string, since it is enclosed in single quote, therefore '2' is a char, and the ASCII value of char '2' is 50..
Therefore the expression is 50 + 50 - 50
and prints 50 as output
+ 1
Thank you so much.