C++ Program To Find ASCII Value Of A Character - Tutorialspoint
Maybe your like
- Home
- Whiteboard
- Online Compilers
- Practice
- Articles
- AI Assistant
- Jobs
- Tools
- Corporate Training
- Courses
- Certifications
- Switch theme
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
There are 128 characters in the ASCII (American Standard Code for Information Interchange) table with values ranging from 0 to 127.
Some of the ASCII values of different characters are as follows −
| Character | ASCII Value |
|---|---|
| A | 65 |
| a | 97 |
| Z | 90 |
| z | 122 |
| $ | 36 |
| & | 38 |
| ? | 63 |
A program that finds the ASCII value of a character is given as follows −
Example
Live Demo
#include <iostream> using namespace std; void printASCII(char c) { int i = c; cout<<"The ASCII value of "<<c<<" is "<<i<<endl; } int main() { printASCII('A'); printASCII('a'); printASCII('Z'); printASCII('z'); printASCII('$'); printASCII('&'); printASCII('?'); return 0; }Output
The ASCII value of A is 65 The ASCII value of a is 97 The ASCII value of Z is 90 The ASCII value of z is 122 The ASCII value of $ is 36 The ASCII value of & is 38 The ASCII value of ? is 63In the above program, the function printASCII() prints the ASCII values of characters. This function defines an int variable i and the value of the character c is stored into this variable. Since i is integer type, the corresponding ASCII code of the character is stored into i. Then the values of c and i are displayed.
This is demonstrated by the following code snippet.
void printASCII(char c) { int i = c; cout<<"The ASCII value of "<<c<<" is "<<i<<endl; }
karthikeya Boyini Updated on: 2020-06-24T07:58:54+05:30 10K+ Views
Kickstart Your Career
Get certified by completing the course
Get StartedTag » How To Get Ascii Value Of Char In C++
-
Get ASCII Value Of Char In C++ | Delft Stack
-
C++ Program To Find ASCII Value Of A Character - Programiz
-
Program To Print ASCII Value Of A Character - GeeksforGeeks
-
C++ Program To Print ASCII Value Of All Characters In The String
-
How To Convert An ASCII Char To Its ASCII Int Value? - Stack Overflow
-
Convert ASCII To Char In C++ - Java2Blog
-
ASCII Chart
-
How Do You Find The ASCII Value Of A Character? - MakeUseOf
-
ASCII Value Of Character In C++ | Programming - PrepInsta
-
Print Character Through ASCII Value Using Cout In C++ - IncludeHelp
-
C++ Program To Find ASCII Value Of Character - Learn ETutorials
-
Program To Print ASCII Value Of A Character - STechies
-
ASCII Character Set
-
Ascii Value Of A Char In Cpp Code Example - Grepper