Advertisement
wiktormadera

zad6

Apr 2nd, 2020
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.71 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. float iloraz (float a, float b)
  6. {
  7.     float iloraz;
  8.     if(b==0)
  9.     {
  10.         return -1;
  11.     }
  12.     else if(a>0&&b>0)
  13.     {
  14.         iloraz = a/b;
  15.         return iloraz;
  16.     }
  17.     else
  18.     {
  19.         return -2;
  20.     }
  21. }
  22. int main()
  23. {
  24.     int a,b;
  25.     float c;
  26.     cout << "Podaj liczbe naturalna a:" << endl;
  27.     cin >> a;
  28.     cout << "Podaj liczbe naturalna b:" << endl;
  29.     cin >> b;
  30.     c=ILORAZ(a,b);
  31.     if(c==-1)
  32.     {
  33.         cout << "Nie dziel przez 0!" << endl;
  34.     }
  35.     else if(c==-2)
  36.     {
  37.         cout << "Liczby naturalne sa wieksze niz 0" << endl;
  38.     }
  39.     else
  40.     {
  41.         cout << "Wynik: " << c << endl;
  42.     }
  43.     return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement