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