Program which will Sum the ascii value of a String | SpiderShell

Program which will Sum the ascii value of a String | SpiderShell   





Program which will Sum the ascii value of a String | SpiderShell
Program which will Sum the ascii value of a String | SpiderShell

Program :


#include <stdio.h>  

int main()  
{  
    int sum=0;  

    char name[50];  

    int i=0;    

    printf("Enter a 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("\n\nSum of the ascii value of a string is : %d", sum);  

    return 0;  

}  

Output : 


Enter a name: shubham 

The ascii value of the character s is 115
The ascii value of the character h is 104
The ascii value of the character u is 117
The ascii value of the character b is 98
The ascii value of the character h is 104
The ascii value of the character a is 97
The ascii value of the character m is 109

Sum of the ascii value of a string is : 744





Shubham Arun Sutar

Author & Editor

Has laoreet percipitur ad. Vide interesset in mei, no his legimus verterem. Et nostrum imperdiet appellantur usu, mnesarchum referrentur id vim.

0 Comments:

Post a Comment