Advertisement
Guest User

Untitled

a guest
Apr 24th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.35 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. int dodaj(int x, int y)
  4. {
  5.   return x + y;
  6. }
  7.  
  8. int odejmij(int x, int y)
  9. {
  10.     return x - y;
  11. }
  12. int pomnoz(int x, int y)
  13. {
  14.   return x * y;
  15. }
  16.  
  17. float podziel(float x, float y)
  18. {
  19.     return(float) (x / y);
  20. }
  21.  
  22.  
  23. int main ()
  24. {
  25.     std::cout << "KALKULATOR" << std::endl;
  26.     std::cout << " " << std::endl;
  27.     std::cout << "1. Dodawanie" << std::endl;
  28.     std::cout << "2. Odejmowanie" << std::endl;
  29.     std::cout << "3. Mnożenie" << std::endl;
  30.     std::cout << "4. Dzielenie" << std::endl;
  31.  
  32.     int x,y;
  33.  
  34.     std::cout << "Podaj dwie liczby:" << std::endl;
  35.     std::cin >> x >> y;
  36.  
  37.  
  38.     std::cout << "Suma wynosi:" << dodaj(x,y) << std::endl;
  39.     std::cout << "Różnica wybosi:" << odejmij(x,y) << std::endl;
  40.     std::cout << "Iloczyn wynosi:" << pomnoz(x,y) << std::endl;
  41.     std::cout << "Iloraz wynosi:" << podziel(x,y) << std::endl;
  42.  
  43.     if(1=dodaj) {
  44.  
  45.        suma: x+y;
  46.        std::cout << "Suma wynosi: " << suma << std:endl;
  47.  
  48.     } else {
  49.  
  50.  
  51.     if(2=odejmij) {
  52.     suma: x-y;
  53.     std::cout << "Różnica wynosi: " << roznica << std:endl;
  54.  
  55.  
  56.     } else {
  57.  
  58.     if(3=pomnoz) {
  59.     suma: x*y;
  60.     std::cout << "Iloczyn wynosi: " << iloczyn << std:endl;
  61.  
  62.     } else {
  63.  
  64.     if(4=pomnoz) {
  65.     suma: x/y;
  66.     std::cout << "Iloraz wynosi: " << iloraz << std:endl;
  67.     } else
  68.  
  69. return 0;
  70.  
  71.  
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement