Sum of Even & Odd Digits Problem Statement

Create a program that accepts an integer N and outputs two sums: the sum of all even digits and the sum of all odd digits found in the integer.

Explanation:

Digits refer to the numbers themselves, not their positional values. For example, if N is "13245", the even digits are 2 & 4, and the odd digits are 1, 3 & 5.

Input:

Integer N

Output:

Sum_of_Even_Digits Sum_of_Odd_Digits

First print the sum of even digits, followed by the sum of odd digits, separated by a space.

Example:

Input:
13245
Output:
6 9
Explanation:

In the input 13245, the even digits are 2 and 4, summing to 6. The odd digits are 1, 3, and 5, summing to 9.

Constraints:

  • 0 <= N <= 10^8
AnswerBot
4mo

Create a program to find the sum of even and odd digits in an integer.

  • Iterate through each digit of the integer and check if it is even or odd

  • Keep track of the sum of even digits and odd digits separa...read more

Patric Andrade
10mo
k=[1,3,2,4,5] even = [] odd = [] for i in k: #print(i) if i % 2 == 0: even.append(i) else: odd.append(i) print("odd: ", odd) print("even: ", even)
Shubham Raj Kumawat
1y

import java.util.Scanner;

public class SumEvenAndOddDigits {

public static void main(String[] args) {

Scanner scanner = new Scanner(System.in);

System.out.print("Enter an integer N: ");

int N = scanner.nextInt();

int evenSum = 0;

int oddSum = 0;

while (N != 0) {

int digit = N % 10;

if (digit % 2 == 0) {

evenSum += digit;

} else {

oddSum += digit;

}

N /= 10;

}

System.out.println("Sum of even digits: " + evenSum);

System.out.println("Sum of odd digits: " + oddSum);

}

}

Abhijit Das
1y
a = int(input()) n = [] for _ in range(a): m = int(input()) n.append(m) even = 0 odd = 0 for x in range(0, len(n)): if n[x] % 2 == 0: even = even + n[x] else: odd = odd + n[x] print(even) print(odd) M...read more
Komari Bhudevi
1y

Namepace SumOfEvenAndOddDigits

{

class Program

{

static void Main(string[] args)

{

Console.Write("Enter an integer: ");

int number = int.Parse(Console.ReadLine());

int sumEven = 0;

int sumOdd = 0;

// C...read more

4JN19IS096 -Spandana K R
2y

def sum_of_even_and_odd_digits(N):

even_sum = 0

odd_sum = 0

while N > 0:

digit = N % 10 # Extract the last digit

if digit % 2 == 0: # Check if the digit is even

even_sum += digit

else:

odd_sum += digi...read more

Select
Add answer anonymously...

Accenture Application Development Associate interview questions & answers

An Application Development Associate was asked 2mo agoQ. Which data type have you used for storing images?
An Application Development Associate was asked 2mo agoQ. What are your thoughts on OOPS concepts?
An Application Development Associate was asked 3mo agoQ. What is your understanding of artificial intelligence (AI)?

Popular interview questions of Application Development Associate

An Application Development Associate was asked 2mo agoQ1. Which data type have you used for storing images?
An Application Development Associate was asked 2mo agoQ2. What are your thoughts on OOPS concepts?
An Application Development Associate was asked 3mo agoQ3. What is your understanding of artificial intelligence (AI)?

Top HR questions asked in Accenture Application Development Associate

An Application Development Associate was asked 2mo agoQ1. Can you provide an explanation of your project?
An Application Development Associate was asked 4mo agoQ2. What are your aspirations and future goals?
An Application Development Associate was asked 5mo agoQ3. Can you tell me about yourself?
Accenture Application Development Associate Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+

Reviews

10L+

Interviews

4 Cr+

Salaries

1.5 Cr+

Users

Contribute to help millions

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

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits