This blog is under construction

Friday 5 July 2013

C program to convert ascii to hexadecimal

Write a C program to convert ASCII to Hexadecimal value.


  #include <stdio.h>
  #include <ctype.h>

  int main() {
        int i;
        printf("ASCII to Hexadecimal:\n");
        printf("Character ASCII  Hexadecimal\n");
        for (i = 'a'; i <= 'z'; i++) {
                printf("\t%c\t%3d\t0x%x\n",
                        i, toascii(i), toascii(i));
        }
        return 0;
  }



  Output:

   jp@jp-VirtualBox:~/$ ./a.out
   Character ASCII  Hexadecimal
a 97 0x61
b 98 0x62
c 99 0x63
d 100 0x64
e 101 0x65
f 102 0x66
g 103 0x67
h 104 0x68
i 105 0x69
j 106 0x6a
k 107 0x6b
l 108 0x6c
m 109 0x6d
n 110 0x6e
o 111 0x6f
p 112 0x70
q 113 0x71
r 114 0x72
s 115 0x73
t 116 0x74
u 117 0x75
v 118 0x76
w 119 0x77
x 120 0x78
y 121 0x79
z 122 0x7a



No comments:

Post a Comment