error_expected_primary expression before in. In functions
Posted
by
user2975402
on Stack Overflow
See other posts from Stack Overflow
or by user2975402
Published on 2013-11-10T03:50:20Z
Indexed on
2013/11/10
3:53 UTC
Read the original article
Hit count: 146
c++
Here is my code. I try to fix it and I always obtain the same error: expected primary expression before 'int'.
in line 47, 55, 63, 80, 86.
And I've already tried this program in small pieces before and it works. It doesn't marked that error.
` #include
using namespace std;
int add (int a, int b)
{
int r;
r=a+b;
return (r);
}
int ssub (int a, int b)
{
int r;
r=a-b;
return (r);
}
int mult(int a, int b)
{
int r;
r=a*b;
return (r);
}
int menu(int a, int b){
int r;
char x;
cout <<"What do you want to do: \na.Adding \n s. Substract \n m. Multiply. \n. e. Exit"<<endl;
cin>>x;
switch (x){
case 'a':
cout << "Give a value for a"<<endl;
cin>>a;
cout <<"Give a value for b"<<endl;
cin>>b;
add (int a, int b); //aquí y en otras líneas me sale: expected primary expression before int.
break;
case 's':
cout << "Give a value for a"<<endl;
cin>>a;
cout <<"Give a value for b"<<endl;
cin>>b;
ssub (int a, int b);
break;
case 'm':
cout << "Give a value for a"<<endl;
cin>>a;
cout <<"Give a value for b"<<endl;
cin>>b;
mult (int a, int b);
break;
case 'e':
x='e';
break;
default:
cout<<"Wrong choice. Run the program again and choose another letter"<<endl;
break;
}
return r;
}
cout<<"The result is " << menu (int a, int b)<<endl;
int main()
{
menu (int a, int b);
return 0;
}
`
© Stack Overflow or respective owner