Advertisement
Guest User

Untitled

a guest
Oct 25th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6. char znak;
  7. int a, b;
  8. float wynik;
  9.  
  10. printf("Podaj znak oraz cyfry\n");
  11. scanf("%c %d %d", &znak, &a, &b);
  12.  
  13. switch(znak)
  14. {
  15. case'+':
  16. {
  17. wynik=a+b;
  18. }
  19. break;
  20.  
  21. case'-':
  22. {
  23. wynik=a-b;
  24. }
  25. break;
  26.  
  27. case'*':
  28. {
  29. wynik=a*b;
  30. }
  31. break;
  32.  
  33. case'/':
  34. {
  35.  
  36. if(b==0)
  37. {
  38. printf("Nie dziel przez zero!");
  39. }
  40. wynik=a/b;
  41. }
  42. break;
  43.  
  44. }
  45. printf("Wynik:", wynik);
  46. system("pause");
  47. return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement