C++ print ascii code – C++ Program to print ASCII Value of All Alphabets

C++ print ascii code: In the previous article, we have discussed C++ Program to Find Power of a Number. In this article, we will see C++ Program to print ASCII Value of All Alphabets.

C++ Program to print ASCII Value of All Alphabets

  • Write a C++ program to print ASCII value of characters.

C++ Program to print ASCII value of a character

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

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

Access the online Sample C++ Programs list from here and clear all your queries regarding the coding and give your best in interviews and other examinations.