Sum of Digits of a Five Digit Number Discussions | C | HackerRank

Sum of Digits of a Five Digit Number

  • + 14 comments
    scanf("%c%c%c%c%c", &a,&b,&c,&d,&e);
    printf("%d\n",(a-48)+(b-48)+(c-48)+(d-48)+(e-48));
    
        I thought it was easiest to to just scan in the char and then subtract out the ascii delta.