AnkitWebLogic

Q1. WAP to Sum the ASCII value of a string 1

#include<stdio.h>
//WAP to Sum the ASCII value of a string
int main()
{
    char name[50];
    int i=0, sum=0;
    printf("Enter name:");
    scanf("%s",&name);
    while(name[i]!='\0')
    {
        printf("\nThe ascii value of the character %c is %d", name[i],name[i]);
        sum=sum+name[i];
        i++;
    }
    printf("\nSum of the ascii value of a string is : %d", sum);
    return 0;
}
Enter name: fun
Sum of the ascii value of a string is : 329