In what concerns the continuous evaluation solving exercises grade during the semester, you should submit until 23:59 of March 24th
(this exercise will still be available for submission after that deadline, but without couting towards your grade)
[to understand the context of this problem, you should read the class #03 exercise sheet]
Have you ever looked at a number and thought, "What if I could just add up all its digits and see what I get?"
Write a program that, given several integers, calculates the sum of the digits of each one. For example, if the input number is 123, the output should be 1 + 2 + 3 = 6.
The first line of input contains an integer T, representing the number of test cases that follow.
Each of the following T lines contains one integer N, representing the number that we want to sum the digits.
The output should have exactly T output lines, one per input test case.
Each of these lines should contain the respective digit sum.
The following limits are guaranteed in all the test cases that will be given to your program:
1 ≤ T ≤ 10 | Number of test cases | |
1 ≤ N ≤ 109 | Number for which we want to sum the digits |
Example Input | Example Output |
4 42 1234 789 16250301 |
6 10 24 18 |
Explanation of Example