[Please help ]Write a c++ program that accpet an integer number from the user ,in case the number is negative check and print out whether it is even or odd number | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

[Please help ]Write a c++ program that accpet an integer number from the user ,in case the number is negative check and print out whether it is even or odd number

31st Jan 2017, 2:20 PM
aulaelf
3 Answers
+ 6
#include <iostream> using namespace std; int main () { int num; cout << "Please input an integer : "; cin >> num; if (num < 0) { cout << "The negative integer is "; if (num % 2 == 0) { cout << "even." << endl; } else { cout << "odd." << endl; } } else { cout << "The input number is a positive integer." << endl; } return 0; }
31st Jan 2017, 4:18 PM
Hatsy Rei
Hatsy Rei - avatar
0
why are you posting your class works here
31st Jan 2017, 2:51 PM
T Key
T Key - avatar
0
Its not class work ok i have an exam and i didnt know how to slove this one so i ask help why i can't ask someone help?
31st Jan 2017, 3:04 PM
aulaelf