26. Program that inputs a number and displays its corresponding ASCII code.

Chapter 4: 

Input And Output

Programming Exercise

Problem # 26:

Write a program that inputs a number and displays its corresponding ASCII code.

Solution:

#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
    char ch;
    cout<<"Enter a number : ";
    cin>>ch;
    cout<<"ASCII : "<<(int)ch<<endl;
    return 0;
}

Let me know in the comment section if you have any question.

Previous Post:
25. Program that inputs principal amount, rate of interest and total time. It calculates the compound interest and displays it.

Comments

  1. Replies
    1. The question is asking for the ASCII corresponding to a number character (0 to 9).

      Delete

Post a Comment