Sum of Even & Odd Digits
You need to determine the sum of even digits and odd digits separately from a given integer.
Input:
The first line of input is an integer T
representing the number of test cases. Each test case consists of a single line with an integer N
.
Output:
For each test case, output two space-separated integers: the sum of even digits and the sum of odd digits, respectively.
Example:
Input:
2
13245
2468
Output:
6 9
20 0
Constraints:
1 <= T <= 5
0 <= N <= 10^{18}
Note:
You do not need to print anything yourself. Just implement the function to return the required values.
AnswerBot
1mo
Implement a function to find the sum of even and odd digits separately in a given integer.
Iterate through each digit of the integer and check if it is even or odd.
Keep track of the sum of even and odd...read more
Help your peers!
Add answer anonymously...
Top TCS Software Developer interview questions & answers
Popular interview questions of Software Developer
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app