forked from waboke/solutions_to_pastquestions_2024
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnumberchecker.cpp
More file actions
33 lines (28 loc) · 725 Bytes
/
Copy pathnumberchecker.cpp
File metadata and controls
33 lines (28 loc) · 725 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
#include <iostream>
using namespace std;
// Function to check if a number is even or odd
void checkEvenOdd(int* num) {
if (*num % 2 == 0) {
cout << *num << " is even." << endl;
} else {
cout << *num << " is odd." << endl;
}
}
// Function to check if a number is positive or negative
void checkPositiveNegative(int* num) {
if (*num > 0) {
cout << *num << " is positive." << endl;
} else if (*num < 0) {
cout << *num << " is negative." << endl;
} else {
cout << *num << " is zero." << endl;
}
}
int main() {
int number;
cout << "Enter a number: ";
cin >> number;
checkEvenOdd(&number);
checkPositiveNegative(&number);
return 0;
}