Home >Backend Development >C++ >C program to print all ASCII values
Prints an American Standard Code for Information Interchange (ASCII) value of 0 to 255 characters without initializing the characters as an integer type variable. Just use format specifiers.
Here we write a program to print only 65 to 122.
If you want to see all ASCII values, in for loop you can write as follows -
For(i=0;i<255;i++)
Then, it prints all ASCII values from 0 to 255.
The logic for printing ASCII values from 65 to 122 is as follows-
Prints ASII values From A to z for (i = 65; i < =122; i++){ printf("%c \t\t %d</p><p>", i, i); }
The following is the C program to print the ASCII values from 65 to 122-
Real-time demonstration
#include <stdio.h> int main() { // Declare Variables int i = 0; printf("Character \t ASCII Value</p><p></p><p>"); //Print ASCII Values for (i = 65; i <=122; i++) { printf("%c \t\t %d</p><p>", i, i); } return 0; }
When the above program is executed, the following output will be generated-
Character 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 90 [ 91 \ 92 ] 93 ^ 94 _ 95 ` 96 a 97 b 98 c 99 d 100 e 101 f 102 g 103 h 104 i 105 j 106 k 107 l 108 m 109 n 110 o 111 p 112 q 113 r 114 s 115 t 116 u 117 v 118 w 119 x 120 y 121 z 122
The above is the detailed content of C program to print all ASCII values. For more information, please follow other related articles on the PHP Chinese website!