Friday 10 November 2017

C Program to Input a String & Store their Ascii Values in an Integer Array & Print the Array


Code:

#include

void main()
{
    char string[20];
    int n, count = 0;
    printf("Enter the no of characters present in an array \n ");
    scanf("%d", &n);
    printf(" Enter the string of %d characters \n" , n);
    scanf("%s", string);
    while (count < n)
    {
        printf(" %c = %d\n", string[count], string[count] );
        ++ count ;
    }
}

Output:

Enter the no of characters present in an array
10
 Enter the string of 10 characters
sanfoundry
 s = 115
 a = 97
 n = 110
 f = 102
 o = 111
 u = 117
 n = 110
 d = 100
 r = 114
 y = 121


More C Programs:













100+ Best Home Decoration Ideas For Christmas Day 2019 To Make Home Beautiful

Best gifts for Christmas Day | Greeting cards for Christmas Day | Gift your children a new gift on Christmas day This Christmas d...