Advertisement
Igor2909

verifica 2

Jan 22nd, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.61 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. main(){
  5.     float a, b, risult;
  6.     printf("Inserisci il primo numero: ");
  7.     scanf("%f", &a);
  8.     printf("Inserisci il secondo numero: ");
  9.     scanf("%f", &b);
  10.     printf("Scegli l'operazione da svolgere: \n1-Somma \n2 - Sottrazione \n3 - Moltiplicazione \n4 - Divisione\n ");
  11.     int s; //scelta
  12.     scanf("%d", &s);
  13.    
  14.     switch(s)
  15.     {
  16.         case 1:
  17.         {
  18.             risult = a+b;
  19.             break;
  20.         }
  21.         case 2:
  22.         {
  23.             risult = a-b;
  24.             break;
  25.         }
  26.         case 3:
  27.         {
  28.             risult = a*b;
  29.             break;
  30.         }
  31.         case 4:
  32.         {
  33.             risult = a/b;
  34.             break;
  35.         }
  36.     }
  37.    
  38.     printf("%f", risult);
  39.     system("PAUSE");
  40.    
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement