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.
2
If the integer x is odd, print "x is odd". If x is even, print "x is even" */
3
4
#include <iostream>
5
using namespace
std;
6
7
int
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
}
main
int main()
Definition
checkpoint3.6.cpp:7
Module3
checkpoint3.6.cpp
Generated on Sun Sep 29 2024 16:39:53 for COMP2113 by
1.12.0