Advertisement
JakubJaneczek

Zadanie 6

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