0

How does write a program to count no of even and odd in the range of 30

11th Jan 2018, 12:27 PM
Ephrem Temeselew
Ephrem Temeselew - avatar
8 Answers
11th Jan 2018, 12:41 PM
Scooby
Scooby - avatar
+ 5
my code start from 0 to 30 thats why result show 15,16.. if start from 1 result is 15,15 on my code..
11th Jan 2018, 1:43 PM
Scooby
Scooby - avatar
+ 4
yeah.. :D lol
11th Jan 2018, 1:46 PM
Scooby
Scooby - avatar
+ 4
ok..check my code..
11th Jan 2018, 2:02 PM
Scooby
Scooby - avatar
+ 1
Exactly half the numbers are even, exactly half the numbers are odd. If your number is odd to begin with, you count one odd number extra. cout << "Number of evens: " << (n/2) << endl; cout << "Number of odds: " << (n/2) + (n%2) << endl;
11th Jan 2018, 1:40 PM
Schindlabua
Schindlabua - avatar
+ 1
He didn't say where the range starts so either is fine :D
11th Jan 2018, 1:45 PM
Schindlabua
Schindlabua - avatar
+ 1
i want to say the no is starts from 0
11th Jan 2018, 1:56 PM
Ephrem Temeselew
Ephrem Temeselew - avatar
0
i have checked
11th Jan 2018, 2:11 PM
Ephrem Temeselew
Ephrem Temeselew - avatar