Lesson 2.2.
This commit is contained in:
parent
52d8787bc4
commit
1c0990b4d1
20
main.cpp
20
main.cpp
@ -1,11 +1,25 @@
|
||||
#include <iostream>
|
||||
|
||||
int test();
|
||||
int promptNumber(const char*);
|
||||
void addSubTwoNumbers();
|
||||
|
||||
int main()
|
||||
{
|
||||
std::cout << test();
|
||||
std::cout << "Add and Subtract 2 Numbers:\n\n";
|
||||
addSubTwoNumbers();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int test() {
|
||||
int promptNumber(const char* prompt) {
|
||||
int toReturn {};
|
||||
std::cout << prompt;
|
||||
std::cin >> toReturn;
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
void addSubTwoNumbers() {
|
||||
int num1 {promptNumber("Enter a integer: ")};
|
||||
int num2 {promptNumber("Enter another integer: ")};
|
||||
std::cout << num1 << " + " << num2 << " = " << num1 + num2 << "\n";
|
||||
std::cout << num1 << " - " << num2 << " = " << num1 - num2 << "\n";
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user