+ 1
c++ program addition, subtraccion, multiplicacion, division of n numeros
i need a C++ program with options menu where you can choose between addition, subtraction, multiplication, and division, which can calculate numbers
1 ответ
+ 2
#include <iostream>
using namespace std;
int main()
{
float a,b,result;
char op;
cin>>a>>b>>op;
switch(op)
{
case'+':result=a+b;
break;
case'-':if(a>b)
result=a-b;
else
result=b-a;
break;
case'*':result=a*b;
break;
case'/':if(b==0)
cout<<"divide by zero !!!";
else
result=a/b;
break;
default:cout<<"wrong operator"; }
cout<<result;
return 0;
}
FOR ANY 2 USER DEFINED NUMBERS !!!