#include
using namespace std;
int main()
{
char x;
cout << \"enter a character:\";
cin >> x;
cout << \"ASCII Val
std::cout << "ASCII Value of " << x << "is" << (int)x;
is one way (the cast circumvents the special treatement of a char
type by the I/O stream library), but this will output your platform's encoded value of the character, which is not necessarily ASCII.
A portable solution is much more complex: You'll need to encode the ASCII set in a 128 element array of elements capable of storing a 7 bit unsigned value, and map x
to a suitable element of that.