C++ Program To Print ASCII Value of a Character Last Updated : 13 Jun, 2024 Comments Improve Suggest changes Like Article Like Report Given a character, we need to print its ASCII value in C++. Examples: Input: a Output: 97 Input: DOutput: 68 Using Type ConversionHere int() is used to convert a character to its ASCII value. Below is the C++ program to implement the above approach: C++ // C++ program to print // ASCII Value of Character #include <iostream> using namespace std; // Driver code int main() { char c = 'A'; cout << "The ASCII value of " << c << " is " << int(c); return 0; } OutputThe ASCII value of A is 65Time complexity: O(1) since performing constant operationsAuxiliary Space: O(1) ASCII Value For Each Character in a StringBelow is the C++ program to print the ASCII value of each character in a string: C++ // C++ program to print ASCII // value of each character in a string #include<iostream> using namespace std; // Driver code int main() { char ch, str[200] = "GeeksforGeeks"; int i = 0, val; cout << "\nCharacter\tASCII Value\n"; while(str[i]) { ch = str[i]; val = ch; cout << ch << "\t\t\t" << val << endl; i++; } cout << endl; return 0; } OutputCharacter ASCII Value G 71 e 101 e 101 k 107 s 115 f 102 o 111 r 114 G 71 e 101 e 101 k 107 s 115ASCII Value of All CharactersBelow is the C++ program to print the ASCII value of all the characters: C++ // C++ program to print AS #include <iostream> using namespace std; // Driver code int main() { char c; cout << "Character\tASCII Value\n"; for(c = 'A'; c <= 'Z'; c++) { cout << c << "\t\t\t" << (int)c << endl; } return 0; } OutputCharacter ASCII Value A 65 B 66 C 67 D 68 E 69 F 70 G 71 H 72 I 73 J 74 K 75 L 76 M 77 N 78 O 79 P 80 Q 81 R 82 S 83 T 84 U 85 V 86 W 87 X 88 Y 89 Z ...Please refer complete article on Program to print ASCII Value of a character for more details! Comment More infoAdvertise with us Next Article C++ Program To Print ASCII Value of a Character K kartik Follow Improve Article Tags : C++ Programs C++ ASCII C Basic Programs Practice Tags : CPP Similar Reads How to Convert ASCII Value into char in C++? In C++, ASCII (American Standard Code for Information Interchange) values are numerical representations of characters that are used in the C++. In this article, we will learn how to convert an ASCII value to a char in C++. Example: Input: int asciiValue = 65; Output: Character for ASCII value 65 is: 2 min read C++ Program To Print Character Pattern Here we will build a C++ Program To Print Character patterns using 2 Approaches i.e. Using for loopUsing while loop Printing 1 character pattern in C++ using different approaches. 1. Using for loop Input: rows = 5 Output: A B B C C C D D D D E E E E E Approach 1: Assign any character to one variable 5 min read C++ Program To Print Continuous Character Pattern Here we will build a C++ Program To Print Continuous Character patterns using 2 different methods i.e: Using for loopsUsing while loopsInput: rows = 5Output: A B C D E F G H I J K L M N O 1. Using for loopApproach 1: Assign any character to one variable for the printing pattern. The first for loop i 5 min read C++ Program For char to int Conversion In C++, we cannot directly perform numeric operations on characters that represent numeric values. If we attempt to do so, the program will interpret the character's ASCII value instead of the numeric value it represents. We need to convert the character into an integer.Example:Input: '9'Output: 9Ex 2 min read C++ Program For int to char Conversion In this article, we will learn how to convert int to char in C++. For this conversion, there are 5 ways as follows: Using typecasting.Using static_cast.Using sprintf().Using to_string() and c_str().Using stringstream. Let's start by discussing each of these methods in detail. Examples: Input: N = 65 6 min read Like