Guest User

Untitled

a guest
Feb 21st, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. #define SUM 1
  4. #define SUB 2
  5. #define MUL 3
  6. #define DIV 4
  7.  
  8. int main()
  9. {
  10. printf("Benvenuto nella calcolatrice\n");
  11. float x,y;
  12. int operazione = 0;
  13. do{
  14. printf("Che operazione vuoi fare? ");
  15. scanf("%d", &operazione);
  16. printf("Inserisci il primo numero: ");
  17. scanf("%f", &x);
  18. printf("Inserisci secondo numero: ");
  19. scanf("%f", &y);
  20. switch(operazione){
  21. case SUM:
  22. printf("%f\n", x+y);
  23. break;
  24. case SUB:
  25. printf("%f\n", x-y);
  26. break;
  27. case MUL:
  28. printf("%f\n", x*y);
  29. break;
  30. case DIV:
  31. printf("%f\n", x/y);
  32. break;
  33. case 0:
  34. printf("Ciao!\n");
  35. break;
  36. default:
  37. printf("Operazione non definita!\n");
  38. break;
  39. }
  40. }while(operazione != 0);
  41. }
Add Comment
Please, Sign In to add comment