COMP2113
COMP2113_ENGG1340 Programming technologies and Computer programming II [Section 2BC] [2023]
Loading...
Searching...
No Matches
checkpoint3.6.cpp
Go to the documentation of this file.
1/* Write a program that reads an integer and determines and prints whether it is odd or even.
2If the integer x is odd, print "x is odd". If x is even, print "x is even" */
3
4#include <iostream>
5using namespace std;
6
7int main(){
8 int x;
9 cin >> x;
10 // negative values provided in test cases
11 if ((x % 2 == 1) || (x % 2 == -1)){
12 cout << x << " is odd";
13 }
14 else
15 cout << x << " is even";
16 return 0;
17}
int main()