C++ Program to Find ASCII Value of a Character
In this program, we will discuss how to find the ASCII value of a character using the C++ programming language.
What is ASCII value?
It stands for American Standard Code for Information Interchange which is a numerical representation of characters in computers ranging from 0 to 127.
A character variable holds ASCII value rather than that character itself in C++ programming language.
For example, Character ‘A’ is represented by 65.
What this means is that, if you assign ‘A’ to a character variable, 65 is stored in that variable rather than ‘A’ itself.
C++ Programming Code to find ASCII value of a character
In this program, we will ask for a character from the user and then print its ASCII value.
Code:-
#include<iostream> using namespace std; int main (){ char c; cout << "Enter a character : "; cin >> c; cout << "ASCII value of " << c <<" is : " << (int)c; return 0; }
Output:-
ASCII value of S is : 83
You can learn about many other C++ Programs Here.
Best Books for learning C++ programming language with Data Structure and Algorithms.
Amit Rawat
Latest posts by Amit Rawat (see all)
- Python Program to Print the Fibonacci Sequence (2 ways) - April 7, 2020
- Python Program to Display or Print Prime Numbers Between a Range or an Interval - June 18, 2019
- Python Program To Print Pascal’s Triangle (2 Ways) - June 17, 2019