I wrote this program which takes the value from the user and makes it into a even number if the number entered was odd, if not then print out a message to say they need to enter a odd number. But the program continues to return a value from the makeEven function even though I just want it to print out the message saying enter an odd number.
I'm relatively new to C++ and just cant get my head around where it is getting the value it happens to print out.
#include <iostream>
using namespace std;
int makeEven(int x)
{
if ( x % 2 != 0 )
return x-1;
else
cout<<"Please enter an odd number!";
goto /*line*/ 18;
}
int main()
{
int x;
cout << "Please enter an integer: ";
cin >> x;
cout << "Your number is now: " << makeEven(x) <<endl;
};