acidrain
Executive Member
Ok so one of the questions in my assignment ask me to calculate the output of the following program:
#include <iostream>
using namespace std;
int main ( )
{
char c, e;
c = 'B';
e = 4 + c;
cout << 2 * c << " and " << e << " and " << e + c << endl;
system("PAUSE");
return EXIT_SUCCESS;
}
Now its all well and easy typing it into the program, running it and ending up with: 132 and F and 136 but i do not understand how it ends up with this conclusion.
I have found out how it gets 132 ( since the ASCII value ( Dec. ) for 'B' is 66 and 66 * 2 = 132 ) but i have no clue how it gets 'F' and '136'.
Help please!
EDIT: Ok i just worked out how it gets 136 ( e + c = 4 + 'B' + 'B' = 4 + 66 + 66 = 136 ) but now using the same method of sunstition e = 4 + c = 4 + 'B' = 4 + 66 = 70, but the program outputs F instead of 70.
Any Ideas why it doesnt output 70?
#include <iostream>
using namespace std;
int main ( )
{
char c, e;
c = 'B';
e = 4 + c;
cout << 2 * c << " and " << e << " and " << e + c << endl;
system("PAUSE");
return EXIT_SUCCESS;
}
Now its all well and easy typing it into the program, running it and ending up with: 132 and F and 136 but i do not understand how it ends up with this conclusion.
I have found out how it gets 132 ( since the ASCII value ( Dec. ) for 'B' is 66 and 66 * 2 = 132 ) but i have no clue how it gets 'F' and '136'.
Help please!
EDIT: Ok i just worked out how it gets 136 ( e + c = 4 + 'B' + 'B' = 4 + 66 + 66 = 136 ) but now using the same method of sunstition e = 4 + c = 4 + 'B' = 4 + 66 = 70, but the program outputs F instead of 70.
Any Ideas why it doesnt output 70?
Last edited: