Monday, 31 August 2020

String Sum Hacker Earth Solution in C

 

https://www.hackerearth.com/practice/basic-programming/implementation/basics-of-implementation/practice-problems/algorithm/string-sum/?layout=old

#include<stdio.h>

int main()
{
    char str[1010];
    scanf(" %s",str);
    int i;
    unsigned long long int ans=0;
    for(i=0;str[i] != '\0';i++)
        ans=ans+str[i]-'a'+1;
    printf("%llu",ans);
}

No comments:

Post a Comment