function help

'isEven' : must return a value is the error I am getting. I dont understand because it is returning a value?

#include <iostream>
#include <cmath>

using namespace std;

int number;
string Even;
string Odd;

int isEven( int x )
{
if (( x % 2) == 0 )
cout << "Even";

else
cout << "Odd";
}

int main()
{
cout << "Please enter number";
cin >> number;

cout << isEven( number );

}
int isEven()

The function promises to return an integer.
You are not returning anything.

change the return type to void.
you can change it to void or just return 0.
void isEven( int x )
{
    if (( x % 2) == 0 )
        cout << "Even";
    else 
        cout << "Odd";
}

int main()
{
     cout << "Please enter number";
     cin >> number;
     isEven( number );
 
    return 0;
}
Topic archived. No new replies allowed.