0

# total of even and odd numbers

the code calculates the total of even numbers and odd numbers, but it does not do it from the array, it counts based on the size of the array. How do i solve this problem. For example, if this was an array of 8 12 23 46 24 56 78 89 34 the program will say there are 4 even numbers and 4 odd, which is not true. i need the program to say there are 6 even numbers and 2 odd numbers. https://code.sololearn.com/cW0ZS0KpKb4W/?ref=app

7 Answers

+ 3

First of all your program was not printing full list of numbers before calculating number of even and odd numbers. Now it does.
Also you was comparing index rather than the array elements, that's why it didn't operate as required.
And lastly you had 4 loops in your code. Now it's 2
Here is a fixed version of your code:
https://code.sololearn.com/cipV9jfNgzW0/?ref=app

+ 1

No problem mate π

0

thanks a lot

0

i have some other problems

0

gimmie a minute

0

Aleksei Radchenkov
divisible by three and five
ive added some other statements but its not working, and it also calculates the numbers divisible by three and five from the array size instead of the random numbers in the array.
https://code.sololearn.com/cW0ZS0KpKb4W/?ref=app

0

Bobby Dike , that seems to work for me....