As we know, each character has its own ASCII value. In this C++ program, we print the ASCII Values of all the characters. In this C++ code, we used for loop (for(i = 0; i <= 255; i++)) to iterate values from 0 to 255. Within that, each number has converted to a character (char)i ).
#include<iostream> using namespace std; int main() { int i; cout << "\nThe ASCII Values of all the Characters are\n"; for(i = 0; i <= 255; i++) { cout << "The ASCII value of " << (char)i << " = " << i << endl; } return 0; }

C++ Program to Print ASCII Values of all Characters using a While loop
#include<iostream> using namespace std; int main() { int i = 0; cout << "\nThe ASCII Values of all the Characters are\n"; while(i <= 255) { cout << "The ASCII value of " << (char)i << " = " << i << endl; i++; } return 0; }
....
The ASCII value of O = 79
The ASCII value of P = 80
The ASCII value of Q = 81
The ASCII value of R = 82
The ASCII value of S = 83
The ASCII value of T = 84
The ASCII value of U = 85
The ASCII value of V = 86
The ASCII value of W = 87
....
This C++ Print ASCII Values of all Characters example allows users to enter the starting and ending ASCII value. Next, it prints the ASCII Values of all the characters between those numbers.
#include<iostream> using namespace std; int main() { int i, start, end; cout << "\nPlease enter the Starting ASCII Value = "; cin >> start; cout << "\nPlease enter the Ending ASCII Value = "; cin >> end; cout << "\nThe ASCII Values of Characters between " << start << " and " << end << " are\n"; for(i = start; i <= end; i++) { cout << "The ASCII value of " << (char)i << " = " << i << endl; } return 0; }
Please enter the Starting ASCII Value = 45
Please enter the Ending ASCII Value = 65
The ASCII Values of Characters between 45 and 65 are
The ASCII value of - = 45
The ASCII value of . = 46
The ASCII value of / = 47
The ASCII value of 0 = 48
The ASCII value of 1 = 49
The ASCII value of 2 = 50
The ASCII value of 3 = 51
The ASCII value of 4 = 52
The ASCII value of 5 = 53
The ASCII value of 6 = 54
The ASCII value of 7 = 55
The ASCII value of 8 = 56
The ASCII value of 9 = 57
The ASCII value of : = 58
The ASCII value of ; = 59
The ASCII value of < = 60
The ASCII value of = = 61
The ASCII value of > = 62
The ASCII value of ? = 63
The ASCII value of @ = 64
The ASCII value of A = 65