#include <iostream>
usingnamespace std;
int timesN (int, int);
int main()
{
int n1, n2, product;
cout <<"Enter the first number you want to multiply"<< endl;
cin>> n1;
cout <<"Enter the second number you want to multiply"<< endl;
cin>> n2;
int timesN(int, int);
cout<< n1 << " times " << n2 << " is " << product << endl;
return 0;
}
int timesN (int number, int N)
{
return (number * N);
}
when i set product equal to timesN i get an error saying there cant be a primary expression before int?
#include <iostream>
usingnamespace std;
int timesN (int, int);
int main()
{
int n1, n2;
cout <<"Enter the first number you want to multiply"<< endl;
cin>> n1;
cout <<"Enter the second number you want to multiply"<< endl;
cin>> n2;
cout<< n1 << " times " << n2 << " is " << timesN(n1,n2) << endl;
return 0;
}
int timesN (int n1, int n2)
{
return (n1 * n2);
}
There, fixed it for you. In your code, in line 25 you try to multiply "number" by "N", but you haven't defined those. Instead you defined "n1" and "n2", so why not use those? Also the integer "product" is redundant, you can just give those values to the "timesN" function directly and get the answer that way.