Need help with function

My Sign function is not displaying correctly. Could use all the help I can get.

//Ask the user to enter a number.
//Then tell the user whether the number is positive or negative and whether the number is even or odd.
//Note that 0 is considered to be even and positive.
//Your program should use two functions beside main and should include input validation.
//After your program has processed a single number, it should ask the user if he wants to try another number.
//If the user answers yes (y), your program should repeat. If the user answers no (n) your program should end.


#include <iostream>
using namespace std;

void GetNum (int& num1);
string Sign (int);

int main()
{
int num1; // Hold for number entered by user
char loopContinue; // Hold Y/N response to continue loop
string even, odd, neg, pos;

do { //Loop until user exits
GetNum(num1);
string Sign();
do {
// Ask user if they want to continue
cout << "Do you want to continue? (Y/N) ";
cin >> loopContinue;
cin.ignore(100, '\n');
loopContinue = toupper(loopContinue);

} while(!((loopContinue == 'Y') || (loopContinue == 'N')));

} while (loopContinue == 'Y');

cout << "OK. Goodbye!";

return 0;
}

void GetNum(int& num1)
{
bool validNumber = true;

do{
cout << "Enter an integer: "; //Prompt user for value
cin >> num1;

if (!cin){
cin.clear();
cin.ignore(100, '\n');
validNumber = false;
cout << "Invalid." << endl;
}
else
{
validNumber = true;
}

} while (!validNumber);

}

string Sign(int num1)
{
string even = " is even", odd = " is odd", neg = " is negative", pos = " is positive";
{
if (num1 < 0)
{
cout << num1 << neg << endl;
}
else
{
cout << num1 << pos << endl;
}
}
{
if (num1 % 2 == 0)
{
cout << num1 << even << endl;
}
else
{
cout << num1 << odd << endl;
}
}
}
Last edited on
closed account (48T7M4Gy)
http://www.cplusplus.com/forum/general/194517/
Topic archived. No new replies allowed.