How can we write a program in c++ that inputs a number and display its corresponding ASCII code???


1 Answers

Ray Dart Profile
Ray Dart answered

This compiles and runs under linux using g++. People forget the cast operator.

#include <iostream>

using namespace std;

int main(int argc, char* argv[], char* envp[])


char inch;

short num;

cout << "Gimme a number" << endl;

cin >> inch;

num = (short)inch;

cout << num << endl;

return 0;


Answer Question