Advertisement
Guest User

Untitled

a guest
Mar 25th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.03 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int add (int a, int b)
  5. {
  6.     int tot;
  7.     tot=a+b;
  8. }
  9. int sub (int a,int b)
  10. {
  11.     int tot;
  12.     tot=a-b;
  13. }
  14. int mul (int a,int b);
  15. int mul (int a,int b)
  16. {
  17.     int tot;
  18.     tot=a*b;
  19. }
  20. float div (float a,float b)
  21. {
  22.     float tot;
  23.     tot=a/b;
  24. }
  25. main ()
  26. {
  27.     float tot1 =33;
  28.     int primo,secondo,scelta;
  29.     cout<<"Inserisci i due numeri: \n";
  30.     cin>>primo;
  31.     cin>>secondo;
  32.     cout<<"Inserisci un numero corrispondente all'operazione che vuoi svolgere: \n";
  33.     cout<<"1. Addizione \n2. Sottrazione \n3. Moltiplicazione \n4. Divisione \n";
  34.     cin>>scelta;
  35.     if(scelta==1 || scelta==2||scelta==3||scelta==4)
  36.     {
  37.         if(scelta==1)
  38.         {
  39.             tot1 = add(primo,secondo);
  40.             cout<<tot1;
  41.         }
  42.         if(scelta==2)
  43.         {
  44.             tot1=sub(primo,secondo);
  45.             cout<<tot1;
  46.         }
  47.         if(scelta==3)
  48.         {
  49.             cout<<"priam"<<tot1<<"\n";
  50.             tot1=mul(primo,secondo);
  51.             cout<<tot1;
  52.         }
  53.         if(scelta==4)
  54.         {
  55.             tot1=div(primo,secondo);
  56.             cout<<tot1;
  57.         }
  58.     }
  59.     else
  60.     {
  61.         cout<<"Non hai scelto un opzione indicata, riprova";
  62.         return 0;
  63.     }
  64.  
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement