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...
TCS Software Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
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

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter