int plus(int a,int b)
{
return a+b;
}
int divide(int a,int b)
{
if(b==0)
{
cout<<"cannot divide by 0";
}
else
{
return a/b;
}
}
int times(int a,int b)
{
return a+b;
}
int minus(int a,int b)
{
return a-b;
}
int main()
{
int a;
int b;
cout<<"Enter two integers ";
cin>>a>>b;
plus(a,b); //error : reference to 'plus' is ambiguos
divide(a,b);
times(a,b);
minus(a,b);
}
Hmmm... Try making a variable in the function "plus". Make it an integer and name it something random... like "x". Set x to equal a + b, and then have the function return it. Like this:
1 2 3 4
int plus(int a, int b){
int x = a + b;
return x;
}
I would try that.
PS: I don't know if it is a typo, but the function times returns a PLUS b, not a times b.
I think its because your code has + operator for plus function and times, you want * not + for times.
this should work....also store your return values to variables
------------------------
#include<iostream>
using namespace std;
int plus(int a,int b)
{
return a+b;
}
int divide(int a,int b)
{
if(b==0)
{
cout<<"cannot divide by 0";
}
else
{
return a/b;
}
}
int times(int a,int b)
{
return a*b;
}
int minus(int a,int b)
{
return a-b;
}
int main()
{
int a;
int b;
cout<<"Enter first integer ";
cin>>a;
cout<<"Enter second integer ";
cin>>b;