Advertisement
Sayukoo

Kalkulatorek

Oct 7th, 2019
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.81 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. float z,x,y;
  4. char c;
  5. int main()
  6. {
  7. printf(">>>KALKULATOR<<<\n");
  8. printf("PIERWSZA LICZBA: "); scanf("%f",&x);
  9. printf("DRUGA LICZBA: "); scanf("%f",&y);
  10. getchar();
  11. printf("Wybierz: \n");
  12. printf("1  Dodawanie \n");
  13. printf("2  Odejmowanie \n");
  14. printf("3  Mnozenie \n");
  15. printf("4  Dzielenie \n");
  16. printf("Podaj nr operacji ktory chcesz wykonac: ");
  17. getchar(c);
  18. switch(c)
  19. {
  20.     case '1': z=x+y; printf("Wynik to: %.1f\n",z);
  21.  
  22.  
  23. break;
  24.     case '2': z=x-y; printf("Wynik to: %.1f\n",z);
  25.  
  26.  
  27. break;
  28.     case '3': z=x*y; printf("Wynik to: %.1f\n",z);
  29.  
  30.  
  31. break;
  32.     case '4': z=x/y;
  33. if(y==0)
  34.     printf("Nie mozna dzielic przez 0");
  35.         else
  36.             printf("Wynik to: %.2f\n",z);
  37.  
  38. break;
  39.  
  40.  
  41.  
  42. }
  43.  
  44.     return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement