Math, asked by naskartathagata5, 4 months ago

write a program to input to 10 different numbers .Display the
sum of even numbers and the sum of odd numbers from.
list of numbers entered by the user using for loop​

Answers

Answered by tsushma01026
0

Answer:

What is a program that will ask for 10 integers and display the sum of all odd numbers, even numbers and all the input integers?

What is a program that will ask for 10 integers and display the sum of all odd numbers, even numbers and all the input integers?

Hint most programming languages have a modulo operator usually in the form of a percent sign which returns the reminder of a division, so after the input of the numbers (this will be your part of the work) you can just loop through them:

tsum=0 # total sum

esum=None # even sum

osum=0 # odd sum

for n in numbers:

#if you don't have the numbers already you

#can get them in the loop instead:

#for i in range(10):

# n=getNumber()

# than continue as in this loop

tsum+=n

if n%2==0:

if esum==None:

esum=n

else:

esum+=n

else:

osum+=n

Similar questions