Here is a source code of the C program to find the sum of the ASCII values of all characters that were used in a string. The C program is successfully compiled and run on a Linux system. The program output is also shown below.
* C Program to Find the Sum of ASCII values of all Characters
* in a String
int sumascii(char , int);
printf("Enter a string: ");
sum = sumascii(str1, 0);
printf("The sum of all ascii values in '%s' is %d.\n", str1, sum);
int sumascii(char str, int num)
if (num < strlen(str))
return (str[num] + sumascii(str, num + 1));
$ gcc asciisum.c $ ./a.out Enter a string: education The sum of all ascii values in 'education' is 956.
Sanfoundry Global Education & Learning Series – 1000 C Programs.