Advertisement
Kacper_Michalak

Zadanie funkcje 10

Jan 30th, 2021
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.92 KB | None | 0 0
  1.  
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. double ILORAZ(double x, double y)
  6. {
  7.     double wynik=0;
  8.     if (x >= 0 && y >= 0)
  9.     {
  10.         if (y != 0)
  11.         {
  12.             wynik = x / y;
  13.             return wynik;
  14.         }
  15.         else return -1;
  16.     }
  17.     else return -2;
  18. }
  19.  
  20. int main()
  21. {
  22.     if (ILORAZ(4, 0) == -2)
  23.     {
  24.         cout << "Nie obsluguje ujemnych" << endl;
  25.     }
  26.     else if (ILORAZ(4, 0) == -1)
  27.     {
  28.         cout << "Nie dziel przez 0" << endl;
  29.     }
  30.     else cout << "wynik z dzielenia wynosi: " << ILORAZ(4, 2) << endl;
  31.  
  32.     if (ILORAZ(5, 3) == -2)
  33.     {
  34.         cout << "Nie obsluguje ujemnych" << endl;
  35.     }
  36.     else if (ILORAZ(5, 3) == -1)
  37.     {
  38.         cout << "Nie dziel przez 0" << endl;
  39.     }
  40.     else cout << "wynik z dzielenia wynosi: " << ILORAZ(5, 3) << endl;
  41.  
  42.     if (ILORAZ(4, -8) == -2)
  43.     {
  44.         cout << "Nie obsluguje ujemnych" << endl;
  45.     }
  46.     else if (ILORAZ(4, -8) == -1)
  47.     {
  48.         cout << "Nie dziel przez 0" << endl;
  49.     }
  50.     else cout << "wynik z dzielenia wynosi: " << ILORAZ(4, -8) << endl;
  51. }
  52.  
  53.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement