-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathex25.cpp
More file actions
50 lines (39 loc) · 668 Bytes
/
ex25.cpp
File metadata and controls
50 lines (39 loc) · 668 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
CPSC 121-0X
Paul De Palma
depalma
Example 25
*/
//A boolean function
#include <iostream>
using namespace std;
bool isOdd(int);
const int MAX = 80;
int main()
{
int num = 0;
char more;
do
{
cout << "Enter an integer " << endl;
cin >> num;
cout << "The number is ";
if (isOdd(num))
cout << "odd";
else
cout << "even";
cout << endl;
cout << "Would you like to try another (y/n)?" << endl;
cin >> more;
} while (more == 'Y' || more == 'y');
}
/*
Pre: num is an integer
Post: returns true if num is odd, false otherwise
*/
bool isOdd(int num)
{
if (num % 2 == 0)
return false;
return true;
}