Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
1.5 kB
1
Indexable
Never
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;

int addTwoIntegers(int num1, int num2);
int subtractTwoIntegers(int num1, int num2);
int multiplyTwoIntegers(int num1, int num2);
double divideTwoIntegers(int num1, int num2);

void displayResults(int num1, int num2, double result, string op);
int getIntegerValue(string prompt);

int main(){
   double result;
   int number1 = getIntegerValue("Enter first integer value: ");
   int number2 = getIntegerValue("Enter second integer value: ");
   result = addTwoIntegers(number1, number2);
   displayResults(number1, number2, result, "+");
   
   result = subtractTwoIntegers(number1, number2);
   displayResults(number1, number2, result, "-");
   
   result = multiplyTwoIntegers(number1, number2);
   displayResults(number1, number2, result, "*");
   
   result = divideTwoIntegers(number1, number2);
   displayResults(number1, number2, result, "/");
   return 0;
}

int getIntegerValue(string prompt){
   int num;
   cout << prompt << endl;
   cin >> num;
   return num;
}

void displayResults(int num1, int num2, double result, string op){
   cout << num1 << " " << op << " " << num2 << " = " << result << endl;
}

int addTwoIntegers(int num1, int num2){
   return num1 + num2;
}

int subtractTwoIntegers(int num1, int num2){
   return num1 - num2;
}

int multiplyTwoIntegers(int num1, int num2){
   return num1 * num2;
}

double divideTwoIntegers(int num1, int num2){
   double answer;
   answer = double(num1) / double(num2);
   return answer;
}