My program is supposed to take numbers from the user and should only stop when 0 is entered. My should then determine the amount of even and odd numbers entered. My program continually accepts numbers and doesnt stop. The number 0 does not have an effect on it.
#include<iostream>
usingnamespace std;
bool IsOdd(int num);
bool IsEven(int num);
int main()
{
int NumOdds=0;
int NumEvens=0;
int num;
cout<<"Please enter an integer followed by enter. Enter 0 when youre finished"<<endl;
cin>>num;
while (!(num=0))
{
if (IsOdd(num))
NumOdds++;
if (IsEven(num))
NumEvens++;
}
cout<<"Number of Even Numbers:"<<NumOdds<<endl;
cout<<"Number of Odd Numbers:"<<NumEvens<<endl;
return 0;
}
bool IsOdd(int num)
{
if (num % 2 == 0)
returnfalse;
returntrue;
}
bool IsEven(int num)
{
return (!IsOdd(num));
}