-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProblemI1.cpp
More file actions
75 lines (57 loc) · 1.59 KB
/
Copy pathProblemI1.cpp
File metadata and controls
75 lines (57 loc) · 1.59 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*
Jingi Min
CIS 22A 2023 Fall
Laboratory Assignment I
ProblemI1
get three numbers, calculate sum and output the output the format
*/
#include <iostream>
using namespace std;
int getData();
int computeTotal(int inputNum1, int inputNum2, int inputNum3);
void printAll(int firstNum, int secondNum, int thirdNum, int numTotal);
int main()
{
int first, second, third, total;
cout << "First integer -> ";
first = getData();
cout << "Second integer -> ";
second = getData();
cout << "Third integer -> ";
third = getData();
total = computeTotal(first, second, third);
printAll(first, second, third, total);
return 0;
}
/**************************
Function purpose: get one integer from the user and return it
parameter: no parameter
return: return integer got from the user
**************************/
int getData()
{
int inputNum;
cout << "Enter one integer: ";
cin >> inputNum;
return inputNum;
}
/***************************
Function purpose: sum three integers and return the value
parameter: inputNum1, inputNum2, inputNum3
return: inputSum
*****************************/
int computeTotal(int inputNum1, int inputNum2, int inputNum3)
{
int inputSum;
inputSum = inputNum1 + inputNum2 + inputNum3;
return inputSum;
}
/***************************
Function purpose: print the values in format
parameter: firstNum, secondNum, thirdNum, total
return: none
*****************************/
void printAll(int firstNum, int secondNum, int thirdNum, int numTotal)
{
cout << firstNum << " + " << secondNum << " + " << thirdNum << " = " << numTotal << endl;
}