Advertisement
Guest User

kalkulator

a guest
Mar 26th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.34 KB | None | 0 0
  1. /*
  2. * program2
  3. *
  4. * Copyright 2017 Tomasz Gromelski <tomgro@sl223-05>
  5. *
  6. */
  7.  
  8.  
  9. #include <stdbool.h>
  10. #include <stdio.h>
  11. #include <stdio.h>
  12. #include <string.h>
  13. #include <stdbool.h>
  14. #include <stdlib.h>
  15. #include <stdint.h>
  16.  
  17. int wczytaj(float d_gran, float g_gran)
  18. {
  19. int wartosc;
  20. scanf("%d", &wartosc);
  21. if (wartosc>d_gran && wartosc<g_gran)
  22. puts("Podana wartosc jest prawidlowa\n");
  23. else
  24. printf("liczba %d nie nalezy do zakresu, podaj liczbe jeszcze raz\n", &wartosc);
  25. return wartosc;
  26. }
  27.  
  28.  
  29. uint16_t oblicz (uint16_t a, uint16_t b, int wybor2)
  30. {
  31. bool kontynuuj=true;
  32. while(kontynuuj)
  33. {
  34. printf("4.1 OR\n4.2 AND\n4.3 XOR\n");
  35. switch(wybor2)
  36. {
  37. case 1:
  38. a &= b ;
  39. break;
  40. case 2:
  41. a |= b;
  42. break;
  43. case 3:
  44. a ^= b;
  45. break;
  46. return a;
  47. }
  48. return 0;
  49. }
  50.  
  51. }
  52.  
  53.  
  54. unsigned konw (uint16_t x);
  55.  
  56. uint16_t wypisz(uint16_t a, uint16_t b, int n)
  57. {
  58. printf("Twoje dane to %f, ",n);
  59. }
  60.  
  61. int main (void)
  62. {
  63. bool kontynuuj=true;
  64. while(kontynuuj)
  65. {
  66. for (int i=1; i<=1000000; i++)
  67. {
  68. printf("1.Wczytaj i wyswietl dane\n");
  69. printf("2.Oblicz sumę.\n");
  70. printf("3.Oblicz różnicę.\n");
  71. printf("4.Mnożenie\n");
  72. printf("0.KONIEC\n");
  73. int wybor;
  74. float a,b,wynik;
  75.  
  76. printf("PODAJ LICZBĘ:");
  77. scanf("%f", &a);
  78. printf("PODAJ DRUGĄ LICZBĘ:");
  79. scanf("%f", &b);
  80. printf("Jakie działanie chcesz wykonać?\n");
  81. scanf("%d", &wybor);
  82.  
  83. switch(wybor)
  84. {
  85. case 1:
  86. wczytaj(0,100000)
  87. ;
  88. case 2:
  89. wynik=a+b;
  90. printf("Wybrałeś dodawanie, jego wynik to:%f\n", wynik);
  91.  
  92. break;
  93. case 3:
  94. wynik=a-b;
  95. printf("Wybrałeś odejmowanie, jego wynik to:%f\n,",wynik);
  96.  
  97. break;
  98. case 4:
  99. wynik=a*b;
  100. printf("Wybrałeś mnozenie, jego wynik to:%f\n",wynik);
  101.  
  102. break;
  103. case 5:
  104.  
  105. oblicz(a,b,wybor);
  106. case 0:
  107. kontynuuj= false;
  108. }
  109. return 0;
  110. }}
  111. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement