47.8k views
5 votes
Write a program in c++ to display the character by entering its ASCII value.

example : Enter ASCII value = 52
Character = 4.

User EENN
by
8.1k points

1 Answer

4 votes

You could do it like this:

#include <iostream>


int main()

{

int c;

do

{

std::cout << "Enter ASCII value (0 to exit): ";

std::cin >> c;

std::cout << "Character = " << char(c) << std::endl;

} while (c > 0);

}

User Luca Braglia
by
7.5k points