not sure why the cout returns 65.
Jul 5, 2017 at 5:12am UTC
Can someone please explain to me why cout << someChar << " "
<< someInt << endl; returns A 65? I understand why it returns A but not sure why 65 as shown on my terminal. Thanks!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main() {
int someInt,
w = 5, x = 9, y = 2, z = 7;
char someChar = 'A' ;
cout << "tryIt3A output \n" ;
z += 3;
cout << z << " " << z % w << endl;
z *= w + y;
cout << z << endl;
z -= 60.1;
cout << z << endl;
cout << (x-1) / (x-w) * y << endl;
cout << (x-1) / ((x-w) * y) << endl;
cout << static_cast <double >(x) / y << endl;
cout << x / y << endl;
cout << (w + x % 7 / y) << endl;
cout << (abs(y - w) + sqrt(x)) << endl;
someInt = someChar;
cout << someChar << " "
<< someInt << endl;
return 0;
}
Jul 5, 2017 at 6:02am UTC
there's
and because the ascii number of A is 65, someInt becomes 65
Last edited on Jul 5, 2017 at 6:02am UTC
Jul 5, 2017 at 6:26am UTC
got it! thanks for explanation!
Topic archived. No new replies allowed.