Hi,
First of all, I'm a newbeginner in C++.
Ok, basically I'm tring to make a calculator with functions. Every function calculates either addition, subtraction, division or multiplication, pretty simple. Though I can't get it to call these functions! Here, take a look at my code:
#include <iostream>
using namespace std;
// Prototyping the functions
int addition(int n1, int n2);
int subtract(int n1, int n2);
int division(int n1, int n2);
int multiply(int n1, int n2);
// Main
int main()
{
// Input, choice
cout << "What do you want to calculate?\n" << endl;
cout << "Addition (1)" << endl;
cout << "Subtraction (2)" << endl;
cout << "Division (3)" << endl;
cout << "Multiplication (4)" << endl;
int choice;
cin >> choice;
// If choice is...
if (choice == 1)
{
addition(int n1, int n2);
}
else if (choice == 2)
{
subtract(int n1, int n2);
}
else if (choice == 3)
{
division(int n1, int n2);
}
else if (choice == 4)
{
multiply(int n1, int n2);
}
}
int addition(int n1, int n2)
{
cout << "Please enter the first number: " << endl;
cin >> n1;
cout << "Now enter the second number: " << endl;
cin >> n2;
cout << n1 << " + " << n2 << " is equal to " << n1 + n2;
return 0;
}
// (I'm gonna add the missing functions here, don't worry! :P)
Yeah. The compiler says "expected primary expression before 'int'". Can anyone help here?Errors are on line 26, 30, 34 and 38.
Thanks!
Chris