This blog is under construction

Monday, 24 June 2013

C program to convert ASCII to character

Write a C program to convert ASCII values to characters.

  #include <stdio.h>
  int main () {
        int data[100], n, i;

        /* get the number of ascii values */
        printf("Enter your no of inputs:");
        scanf("%d", &n);

        /* get the ascii values from the user */
        for (i = 0; i < n; i++)
                scanf("%d", &data[i]);

        /* convert & print ascii values to characters */
        for (i = 0; i < n; i++)
                printf("ASCII charater for %d is %c\n", data[i], data[i]);

        return 0;

  jp@jp-VirtualBox:~/$ ./a.out
  Enter your no of inputs:5
  ASCII charater for 65 is A
  ASCII charater for 75 is K
  ASCII charater for 78 is N
  ASCII charater for 67 is C
  ASCII charater for 80 is P

No comments:

Post a Comment