Add two ASCII values?

In my C++ program, it contains 2 CHAR variables and the idea is to add these two together.
For example the decimal number 5 (53 ASCII) + decimal 6 (54 ASCII), when you add these two they should give you 5+6=11 Decimal (53+54=107 ASCII) but 107 isn't the number 11 in ASCII, it is the character "k".

My question is: How can i make sure that the decimal number 11 can be interpreted in ASCII, What process do I have to do, so it can be shown on console?
From what I understood, you have 2 numbers as char variables, and you want to add them together? I think c=(int)a+(int)b should work.
To convert a character digit to an integer, you could subtract the character '0'.
for example
1
2
3
4
5
6
char a = '5';
char b = '6';
int x = a - '0';
int y = b - '0';
int z = x + y;
cout << z; 


Last edited on
Yep, thanks desin and Chervil, the latter was the one i needed, subtracting the character '0' did the job! =)
Topic archived. No new replies allowed.