please tell me what's wrong with the program
thx.
Code:
#include<iostream>
#include<cmath>
#include<fstream>
using namespace std;
void menu();
void fuc1();
void fuc2();
double calculate(double);
int main()
{
char choice;
menu();
cout<<"Enter choice: ";
cin>>choice;
if(choice=='+'||'-'||'*'||'/'||'%'||'P'||'A'||'X')
fuc1();
else if(choice=='R'||'F'||'T')
fuc2();
else
exit;
system("pause");
return 0;
}
void menu()
{
cout<<"+,-,*,/,%"<<endl;
cout<<"A\t averge"<<endl;
cout<<"X\t maximum"<<endl;
cout<<"P\t a^b"<<endl;
cout<<"R\t reciprocal"<<endl;
cout<<"F\t factorial"<<endl;
cout<<"T\t square root"<<endl;
cout<<"Q\t quit"<<endl;
}
void fuc1()
{
int operand1,operand2,result;
char choice;
cout<<"Enter two values you want to calculate: ";
cin>>operand1 >>operand2;
if(choice=='+')
result=operand1+operand2;
if(choice=='-')
result=operand1-operand2;
if(choice=='*')
result=operand1*operand2;
if(choice=='/')
result=operand1/operand2;
if(choice=='%')
result=operand1%operand2;
if(choice=='P')
result=pow((double)operand1,(double)operand2);
if(choice=='A')
result=(operand1+operand2)/2;
else
if(operand1>operand2)
result=operand1;
else
result=operand2;
cout<<choice<<" "<<result<<" "<<operand1<<" "<<operand2<<endl;
}
void fuc2()
{
double operand1,result;
char choice;
cout<<"Enter one value you want to calculate: ";
cin>>operand1;
calculate(operand1);
cout<<choice<<" "<<result<<" "<<operand1<<endl;
}
double calculate(double x)
{
char choice;
double result;
if(choice=='R')
result=1/x;
else if(choice=='F')
for(int i=1;i<=x;i++)
result*=i;
else
result=sqrt(x);
return result;
}