Advertisement
Guest User

Untitled

a guest
Nov 20th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4.  
  5. int enterNumber(double *px)
  6. {
  7. int t;
  8. do{
  9. printf("\nPodaj x: ");
  10. fflush(stdin);
  11. t=scanf("%lf",&(*px));
  12. if(t==0)
  13. return 0;
  14. }while(t==0);
  15. return 1;
  16. }
  17. double suma(double x, double y)
  18. {
  19. return x+y;
  20. }
  21. double roznica(double x, double y)
  22. {
  23. return x-y;
  24. }
  25. double iloczyn(double x, double y)
  26. {
  27. return x*y;
  28. }
  29. int iloraz(double x, double y, double *wynik)
  30. {
  31. if(y==0)
  32. return y;
  33. if(y!=0)
  34. {
  35. *wynik = x / y;
  36. return 1;
  37. }
  38. }
  39.  
  40. int main(int argc, char *argv[]) {
  41. double k,x,y,wynik;
  42. //===========WSKAZNIKI=========
  43. double *px=&x;
  44. double *pwynik=&wynik;
  45. //===========WŁAŚCIWY PROGRAM==========
  46. printf("Witaj mr.Kalkulator");
  47. int powtorka;
  48. do{
  49. enterNumber(px);
  50. y=*px;
  51. enterNumber(px);
  52. printf("\nPodane liczby to: %lf, %lf", *px,y);
  53.  
  54. k=suma(x,y);
  55. printf("\nSuma liczb to: %lf", k);
  56. k=roznica(x,y);
  57. printf("\nRoznica liczb to: %lf", k);
  58. k=iloczyn(x,y);
  59. printf("\nIloczyn liczb to: %lf", k);
  60. k=iloraz(x,y,pwynik);
  61. if(k==0){
  62. printf("Debilu nie dziel przez 0");
  63. }
  64. else
  65. printf("\nIloraz liczb to: %lf", *pwynik);
  66. printf("\nJeśli chcesz powtorki wciśnij 't' ");
  67. powtorka=0;
  68. scanf("%d",&powtorka);
  69. }while(powtorka==1);
  70. return 0;
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement