Saturday, September 3, 2011

Get integer value of char


The function int(c) returns the integer value associated with a character variable c.

Get integer value of char

#include <iostream>


using namespace std;

int main()
{
for (char i = 'A'; i <= 'Z'; i++){
cout << i << " : " << int(i) << endl;
}

for (char i = 'a'; i <= 'z'; i++){
cout << i << " : " << int(i) << endl;
}
return 0;
}



No comments:

Post a Comment