The program allows the user to choose what operation to use first before the user can input 5 numbers.
im trying to lessen my line of codes by creating a function that will get 5 numbers of user inputs so i can just call that function every time it is needed instead of typing it all 4times inside my if else statement.
the problem is when i called the inputs function inside my if else statement it does not read the values inputted inside the inputs function.
this is my code.
#include <iostream>
using namespace std;
int main() {
char Choice;
cout << "MATH OPERATIONS\n[+]\tAddition\n[-]\tSubtraction\n[*]\tMultiplication\n[/]\tDivision";
cout << "\nEnter you Choice: ";
cin >> Choice;
if ( Choice == '+') {
inputs();
double answer = num1 + num2 + num3 + num4 + num5;
cout << "Sum : " << answer << endl;
}
else if (Choice == '-') {}
else if (Choice == '*') {}
else if (Choice == '/') {}
else {}
}
int inputs(int num1, int num2, int num3, int num4, int num5) {
cout << "1st Number: ";
cin >> num1;
cout << "2nd Number: ";
cin >> num2;
cout << "3rd Number: ";
cin >> num3;
cout << "4th Number: ";
cin >> num4;
cout << "5th Number: ";
cin >> num5;
}