0
How does write a program to count no of even and odd in the range of 30
8 Antworten
+ 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..
+ 4
yeah.. :D lol
+ 4
ok..check my code..
+ 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;
+ 1
He didn't say where the range starts so either is fine :D
+ 1
i want to say the no is starts from 0
0
i have checked