+ 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

17th Aug 2016, 5:27 PM
Andres García
Andres García - avatar
1 Réponse
+ 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 !!!
17th Aug 2016, 9:12 PM
Asim
Asim - avatar