1
0
LearningCPP/main.cpp

26 lines
622 B
C++
Raw Normal View History

2022-08-12 14:59:08 +01:00
#include <iostream>
2022-08-13 23:29:56 +01:00
int promptNumber(const char*);
void addSubTwoNumbers();
2022-08-13 00:34:25 +01:00
2022-08-12 14:59:08 +01:00
int main()
{
2022-08-13 23:29:56 +01:00
std::cout << "Add and Subtract 2 Numbers:\n\n";
addSubTwoNumbers();
return 0;
2022-08-12 14:59:08 +01:00
}
2022-08-13 00:34:25 +01:00
2022-08-13 23:29:56 +01:00
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";
2022-08-13 00:34:25 +01:00
}