C++ Program to print ASCII Value of All Alphabets

C++ program to print ASCII value of characters.


C++ Program to print ASCII value of a character

#include <iostream>

using namespace std;
 
int main() {
    char c;
    
    cout << "Enter a Character\n";
    cin >> c;
    // Prints the ASCII value of character
    cout << "ASCII value of " << c << " is " << (int)c;
     
    return 0;
}
Output
Enter a Character
A
ASCII value of A is 65
Enter a Character
a
ASCII value of a is 97

C++ Program to print ASCII value all alphabets

#include <iostream>

using namespace std;
 
int main() {
    char c;

    // Prints the ASCII value of all Uppercase Alphabet
    for(c = 'A'; c <= 'Z'; c++){
       cout << c << " = " << (int)c <<endl;
    }
     
    return 0;
}
Output
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 = 90 

Recommended Posts
C++ Program to Print Multiplication Table of a Number
C++ Program to Print Floyd Triangle
C++ Program to Print Pascal Triangle
C++ Program to Display Fibonacci Series using Loop and Recursion
C++ Program to Display Factors of a Number
C++ Program to Add Two Matrix
C++ Program to Find Area and Circumference of a Circle
C++ Program to Find Area and Perimeter of Parallelogram
C++ Program to Store Information of a Book in a Structure
C++ Program to Copy String Without Using strcpy
C++ Program to Find Sum of Natural Numbers Using Recursion
All C++ Programs