using namespace std;
int main()
{
double num=0, den=0, result=0, max=256;
char op;
do {
cout<<"\nCalculator - Enter Number: ";
cin>>num;
if(num>max){cout<<endl<<"You have exceeded the maximum number of!";}
else{cout<<"Enter operator : +, -, *, /, ^, % : ";
cin>>op;
if (op!='%'){cout<<"enter second number: "; cin>>den;}
if(den>max){cout<<endl<<"You have exceeded the maximum number of!";}
else{
if (op=='+') result=num+den;
if (op=='-') result=num-den;
if (op=='*') result=num*den;
if (op=='/') result=num/den;
if (op=='^') result=pow(num, den);
if (op=='%') result=num/100;
cout<<endl<<"Result: "<<result;
}
}
cout<<endl<<"Exit? y/n"<<endl;
cin>>op; if(op=='y'){return 0;}
}
while (1);
return 0;
}
Comments