-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathValueReturningAddEvenOddDEMO.cpp
More file actions
57 lines (44 loc) · 1.25 KB
/
Copy pathValueReturningAddEvenOddDEMO.cpp
File metadata and controls
57 lines (44 loc) · 1.25 KB
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
51
52
53
54
55
56
57
//************************************************************************
// Author: Rolando Carreon
// Date: jan 28 2025
// Language: C++
// Assignment: Demo
// Description: Hello World Program
//************************************************************************
#include<iostream>
using namespace std;
// function protooypes
int add(int, int);
bool isEven(int);
int main()
{
// declare local variables
int sum = add (5, 3);
// display the sum
cout << "The sum is: " << sum << endl;
// display odd/ even for a number
if( isEven(4) )
cout << "The number is even.\n";
else
cout << "The number is odd.\n";
// display odd/ even for another number
if( isEven(7) )
cout << "The number is even.\n";
else
cout << "The number is odd.\n";
return 0;
}
// function definitions
//function accepts two integer values, sum the caluesm and returns
// the sum of the values
int add(int firstNum, int secondNum)
{
return firstNum + secondNum;
}
// function that excepts and integer paramater, determines if the value
// is even or odd. if its even return true, if odd return false
bool isEven(int number)
{
// modulo 2 returns 0 if even, 1 if odd
return number % 2 == 0;
}