Sum of Digits | Problem - 38 | Beginner level | C language | CodeChef

Link to the problem statement: https://www.codechef.com/submit/FLOW006


Solution: The solution is already given, you just have to click on SUBMIT CODE button.

//We have populated the solutions for the 10 easiest problems for your support.
//Click on the SUBMIT button to make a submission to this problem.

#include <stdio.h>

int main(void) {
int t;
scanf("%d",&t);
while (t--){
    int n,m,sum=0;
    scanf ("%d",&n);
    while(n>0){
        
        m=n%10;
        n=n/10;
    
        sum=sum+m;
    }
        printf("%d\n",sum);
}
return 0;
}


Hope this will help you, if you want anything else leave a comment.

Thank you 

Comments

Popular posts from this blog

My very 1st contest! | Problem - 1 | Beginner level | C language | CodeChef

Implementing linked list in C language

Score High | Problem - 4 | Beginner level | C language | CodeChef