Home > Backend Development > C++ > C program to print all ASCII values

C program to print all ASCII values

PHPz
Release: 2023-08-29 23:25:08
forward
1511 people have browsed it

C program to print all ASCII values

Problem

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.

Solution

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++)
Copy after login

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);
}
Copy after login

Example

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;
}
Copy after login

Output

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
Copy after login

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!

Related labels:
source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template