#include <iostream>
using namespace std;
void calc () {
double num1, num2, result;
char op;
cout << "Enter your first number \n";
cin >> num1;
cout << "Now enter your second number \n";
cin >> num2;
cout << "And last but not least, what operator do you want to use? \n";
cin >> op;
if (op == '*') {
result = num1 * num2;
}
else if (op == '+') {
result = num1 + num2;
}
else if (op == '-' || op == '-') {
result = num1 - num2;
}
else if (op == '/') {
result = num1 / num2;
}
else {
cout << "Invalid operator";
}
cout << "The result is " << result << endl;
}
}
int main()
{
calc();
//cout - console output
//endl - end line
//cin - console input
// >> - input
}
so thats my code, and i was hoping to get the calc() function inside a different .cpp file, and then somehow include it into the main file (it will just make the whole project look cleaner in my opinion, thats why i want to do that)