Computer Science, asked by mr9876ravi, 1 month ago

Find display the sum of even and odd numbers among 10 numbers​

Answers

Answered by samiyafathima
1

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

Answered by XxHeartKillerGirl7xX
1

Answer:

C Program to Calculate the Sum of Odd & Even Numbers

Take the number N upto which we have to find the sum as input.

Using for loop take the elements one by one from 1 to N.

Using if,else statements separate the element as even or odd.

Add the even and odd numbers separately and store it in different variables.

Similar questions