Sum of Digits of a Five Digit Number | HackerRank
Problem Link : Sum of Digits of a Five Digit Number
Solution :
Develop by Samsus Salehin Sabbir
- #include <stdio.h>
- #include <string.h>
- #include <math.h>
- #include <stdlib.h>
- int main() {
- int n,i,sum=0,rem;
- scanf("%d", &n);
- //Complete the code to calculate the sum of the five digits on n.
- while(n!=0)
- {
- rem =n%10;
- sum=sum +rem;
- n=n/10;
- }
- printf("%d\n",sum);
- return 0;
- }
No comments