# Answer to Question #49117 in C++ for Salman

Question #49117

Take an integer from user and tell if it is a positive even number, or positive odd, or negative

even or negative odd

even or negative odd

Expert's answer

/* Answer on Question #49117- Subject - Programming, C++ */

#include <cstdlib>

#include <iostream>

using namespace std;

int main()

{

int n; // integer

cout << "Enter an integer: ";

cin >> n; //read integer

if ((n > 0) && ( n % 2 )) // check if integer is positive and odd

cout<<"integer is positive odd"<<endl;

else if ((n < 0) && (n % 2)) // check if integer is negative and odd

cout<<"integer is negative odd"<<endl;

if ((n > 0) && !( n % 2 )) // check if integer is positive and even

cout<<"integer is positive even"<<endl;

else if ((n < 0) && !(n % 2)) // check if integer is negative and even

cout<<"integer is negative even"<<endl;

system("PAUSE");

return EXIT_SUCCESS;

}

#include <cstdlib>

#include <iostream>

using namespace std;

int main()

{

int n; // integer

cout << "Enter an integer: ";

cin >> n; //read integer

if ((n > 0) && ( n % 2 )) // check if integer is positive and odd

cout<<"integer is positive odd"<<endl;

else if ((n < 0) && (n % 2)) // check if integer is negative and odd

cout<<"integer is negative odd"<<endl;

if ((n > 0) && !( n % 2 )) // check if integer is positive and even

cout<<"integer is positive even"<<endl;

else if ((n < 0) && !(n % 2)) // check if integer is negative and even

cout<<"integer is negative even"<<endl;

system("PAUSE");

return EXIT_SUCCESS;

}

``

Need a fast expert's response?

Submit orderand get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

## Comments

## Leave a comment