In this tutorial you will learn about the C++ Program to Find ASCII Value of a Character and its application with practical example.
C++ Program to Find ASCII Value of a Character
In this tutorial, we will learn to create a C++ program that will find the ASCII Value of a Character in C++ programming.
Prerequisites
Before starting with this tutorial we assume that you are best aware of the following C++ programming topics:
- Operators in C++ Programming.
- Basic Input and Output function in C++ Programming.
- Basic C++ Programming.
Program to Find ASCII Value of a Character:-
American Standard Code For Information Interchange stands for ASCII. The ASCII is an encoded format. In c++ programming, we can take the input from the user in character format. In today’s program, we will take input in character format. Secondly, we will find the ASCII Value of a Character the input with the help of a small program. The ASCII values are the most useful code in any programing language to know the characters.
Algorithm:-
1 2 3 4 5 6 7 8 9 |
1. Declaring the variables for the program. 2. Taking the input character form the user for the program to find the ascii value. 3. Finding the ascii walue for the character input. 4. Printing the American Standard Code For Information Interchange value for the user. 5. End program. |
Program:-
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
/* C++ Program to Find ASCII Value of a Character */ #include <iostream> using namespace std; int main() { /* declaring the variables required for the program in character format type */ char c; /* taking the input charcter value form user for the program. */ cout << "Enter a character: "; /* taking the input character value for the program. */ cin >> c; /* Printing the American Standard Code For Information Interchange ASCII value for the input character. */ cout << "ASCII Value of " << c << " is " << int(c); return 0; } |
Output:-
In the above program, we have first initialized the required variable.
- c = it will hold the integer value of the Remainder.
Taking Input divisor and dividend from the user.
Calculating the quotient and the remainder.
Printing the output.