Advertisement
STANAANDREY

calcuL

Dec 3rd, 2018
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.80 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5.  
  6. int main()
  7. {
  8.   unsigned long x,a,b,e;
  9.  
  10. do {
  11.       cout<<"1.adunare"<<endl;
  12.       cout<<"2.scadere(in modul)"<<endl;
  13.       cout<<"3.inmultire"<<endl;
  14.       cout<<"4.impartire(doar catul)"<<endl;
  15.       cout<<"5.exit"<<endl;
  16.       cout<<"optiunea dvs e:"<<'\t';
  17.       cin>>x;
  18.  
  19.       if (x!=5){
  20.      cout<<"a=";cin>>a;
  21.      cout<<"b=";cin>>b;
  22.       }
  23.      switch (x)
  24.      {
  25.          case 1:e=a+b;break;
  26.          case 2:e=abs((double)a-(double)b);break;
  27.          case 3:e=a*b;break;
  28.          case 4:e=(a>b)?a/b:b/a;break;
  29.          default : if (x!=5)
  30.          cout<<"optiune invalida"<<endl;
  31.  
  32.      }
  33.        if (x!=5)
  34.      cout<<"E="<<e<<endl;
  35.      else
  36.         cout<<"mersi pt utilizare"<<endl;
  37.   }  while (x!=5);
  38.  
  39.     return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement