#include <iostream>
#include <cstdlib>
using namespace std;
// function prototype for add
int add (int x, int y);
int sub (int q, int r);
int mul (int s, int t);
int divi (int u, int v);
int main ()
{
int a,b;

char ch;
loop:cout<<"ENTER CHOICE OF OPERATION: +  - OR *  / and q to quit";
cout<<'\n';
cin>>ch;
int result;

if(ch!='+'&&ch!='-'&&ch!='*'&&ch!='/'&&ch!='q')

{
cout<<"wrong input";
}

else
{
if(ch=='+')
{
result = add( a, b );
}
else if(ch=='-')
{
result=sub(a,b);
}
else if(ch=='*')
{
result=mul(a,b);
}
else if(ch=='/')
{
result=divi(a,b);
}
else if(ch=='q')
{
exit(0);
}
cout<<"enter 1st number";
cin>>a;
cout<<"enter 2nd number";
cin>>b;

}

cout << "The result is: " << result << '\n';

goto loop;
}

int add (int x, int y)

{
return x + y;

}
int sub (int q, int r)

{
return q-r;

}
int mul (int s, int t)

{
return s*t;

}
int divi (int u, int v)

{
return u/v;

}

the program is not calculating the operatons i performed, instead its returning random valuesi dont c watt is wrng...plzzzz hlpp

#include <iostream>
#include <cstdlib>
using namespace std;
// function prototype for add
int add (int x, int y);
int sub (int q, int r);
int mul (int s, int t);
int divi (int u, int v);
int main ()
{
int a,b;

char ch;
loop:cout<<"ENTER CHOICE OF OPERATION: +  - OR *  / and q to quit";
cout<<'\n';
cin>>ch;
int result;

if(ch!='+'&&ch!='-'&&ch!='*'&&ch!='/'&&ch!='q')

{
cout<<"wrong input";
}
else if(ch=='q')
{
exit(0);
}

else
{
cout<<"enter 1st number";
cin>>a;
cout<<"enter 2nd number";
cin>>b;

if(ch=='+')
{
result = add( a, b );
}
else if(ch=='-')
{
result=sub(a,b);
}
else if(ch=='*')
{
result=mul(a,b);
}
else if(ch=='/')
{
result=divi(a,b);
}

}

cout << "The result is: " << result << '\n';

goto loop;
}

int add (int x, int y)

{
return x + y;

}
int sub (int q, int r)

{
return q-r;

}
int mul (int s, int t)

{
return s*t;

}
int divi (int u, int v)

{
return u/v;

}

I fixed it myself thanssss!!!!!!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.