Write a C program to print ASCII value of all characters and numbers.
int main() {
int i;
printf(" ASCII CHARACTER ASCII CHARACTER\n");
/* prints ascii value for the characters 0-9 */
for (i = 0; i < 5; i++) {
printf(" %d %d\t\t%d %d\n",
i + '0', i, (i + 5) + '0', (i + 5));
}
printf("\n");
/* prints ascii value for the characters a-z & A-Z */
for (i = 0; i < 26; i++) {
printf(" %d %c\t\t%3d %c\n",
(i + 'A'), (i + 'A'), (i + 'a'), (i + 'a'));
}
return 0;
}
Output:
jp@jp-VirtualBox:~/$ ./a.out
ASCII CHARACTER ASCII CHARACTER
48 0 53 5
49 1 54 6
50 2 55 7
51 3 56 8
52 4 57 9
65 A 97 a
66 B 98 b
67 C 99 c
68 D 100 d
69 E 101 e
70 F 102 f
71 G 103 g
72 H 104 h
73 I 105 i
74 J 106 j
75 K 107 k
76 L 108 l
77 M 109 m
78 N 110 n
79 O 111 o
80 P 112 p
81 Q 113 q
82 R 114 r
83 S 115 s
84 T 116 t
85 U 117 u
86 V 118 v
87 W 119 w
88 X 120 x
89 Y 121 y
90 Z 122 z
ASCII CHARACTER ASCII CHARACTER
48 0 53 5
49 1 54 6
50 2 55 7
51 3 56 8
52 4 57 9
65 A 97 a
66 B 98 b
67 C 99 c
68 D 100 d
69 E 101 e
70 F 102 f
71 G 103 g
72 H 104 h
73 I 105 i
74 J 106 j
75 K 107 k
76 L 108 l
77 M 109 m
78 N 110 n
79 O 111 o
80 P 112 p
81 Q 113 q
82 R 114 r
83 S 115 s
84 T 116 t
85 U 117 u
86 V 118 v
87 W 119 w
88 X 120 x
89 Y 121 y
90 Z 122 z
No comments:
Post a Comment