0
How to get sum of even and odd number separately using while loop
Using While loop is mandatory . Range should be decided by user
5 odpowiedzi
+ 3
It's simple. Just check
if n%2 == 0
evenSum+= n
else
oddSum += n
+ 3
Mirielle, by using your code with range 1,11 (means using 1 including 10), the result of even is 30 and odd is 24. Shoud odd not be 25?
+ 2
Ayush Khandelwal, have you done a try to solve this task before asking here? It would be nice if you can share it with us.
+ 2
here is an other sample with range and while:
https://code.sololearn.com/ck74DhRwXDSJ/?ref=app
0
what programming language? and what range of numbers?