Hello Programmers In this post, you will know how to solve the Sum of Digits Test Codechef Solution.Sum of Digits Test Codechef SolutionOne more thing to add, don’t directly look for the solutions, first try to solve the problems of Codechef by yourself. If you find any difficulty after trying several times, then you can look for solutions.ProblemYou’re given an integer N. Write a program to calculate the sum of all the digits of N.InputThe first line contains an integer T, the total number of testcases. Then follow T lines, each line contains an integer N.Output For each test case, calculate the sum of digits of N, and display it in a new line.Constraints1 <= T <= 10001 <= N <= 1000000ExampleInput:3 12345 31203 2123 Output:15 9 8Sum of Digits CodeChef Solutions in Pythonn = int(input()) for _ in range(n): num = input() sum = 0 for i in num: sum += int(i) print(sum)Sum of Digits CodeChef Solutions in CPP#include <bits/stdc++.h> using namespace std; int main() { int n; cin>>n; while(n--) { int num,m,sum=0; cin>>num; while(num>0) { m=num%10; sum+=m; num/=10; } cout<<sum<<"\n"; } return 0; } Sum of Digits CodeChef Solutions in JAVAimport java.io.*; public class Main { private static void digitSum() throws IOException { int digit,sum; final BufferedReader br = new BufferedReader( new InputStreamReader(System.in)); final int t = Integer.parseInt(br.readLine()); for(int i=0 ; i<t ;i++) { sum = 0; final int n = Integer.parseInt(br.readLine()); int temp = n; for( ;temp>0 ; temp=temp/10) { digit = temp%10; sum+=digit; } System.out.println(sum); } } public static void main(String[] args) throws IOException{ // TODO Auto-generated method stub digitSum(); } }Disclaimer: The above Problem (Sum of Digits) is generated by CodeChef but the solution is provided by BrokenProgrammers. This tutorial is only for Educational and Learning purpose.Note:- I compile all programs, if there is any case program is not working and showing an error please let me know in the comment section. If you are using adblocker, please disable adblocker because some functions of the site may not work correctly.Next: Enormous Input Test Codechef Solution Post navigationSmall Factorials Codechef Solution Enormous Input Test Codechef Solution