13,731,771 members
See more:
How can I ask if a number is even/odd and positive/negative at the same time?
I've already done the program that asks if a number is positive or negative, but I have no idea how to add (input % 2 == 0) into it.

Thank you.

What I have tried:

```int main()
{
int input;
cout << "Please enter a number\n";
cout << ":";
cin >> input;

if (input > 0)         {

cout << input << " is a positive number" << endl;

}
else if (input == 0)
{

cout << input << " is neither positive nor negative number " << endl;
}
else
{
cout << input << " is a negative number " << endl;
}
return 0;
}```
Posted 20-May-17 11:37am
Updated 20-May-17 20:11pm
NotPolitcallyCorrect 20-May-17 17:43pm

https://msdn.microsoft.com/en-us/library/c6s3h5a7.aspx

## Solution 1

This a good example of "Algorithm First, Coding Second".
The strategy here is "Divide and Conquer" - First find out the positiveness and evenness of the input SEPARATELY, then make the decision based on the combination of these findings.
Use this pseudo code as a guide:
```GET input
SET isEven = 0 // default to odd
SET isPositive = 0  // default to neutral

// Determine positiveness
IF (input > 0) THEN
SET isPositive = 1  // is positive
ELSE IF (input < 0) THEN
SET isPositive = -1 // is negative

// Determine evenness
IF (input % 2 == 0) THEN
SET isEven = 1 // is even

// Decision based on the combined finding of positiveness and evenness
IF (isPositive == 1 AND isEven == 1) THEN
PRINT 'input is positive and even.'
// Figure out the rest yourself...
ELSE IF () THEN
// ...
ELSE
//...```
v3

Top Experts
Last 24hrsThis month
 OriginalGriff 301 MadMyche 100 Richard MacCutchan 88 John Simmons / outlaw programmer 75 George Swan 50
 OriginalGriff 4,520 Richard MacCutchan 1,464 CPallini 1,084 Patrice T 1,061 Dave Kreskowiak 980