Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- double ILORAZ(double x, double y)
- {
- double wynik=0;
- if (x >= 0 && y >= 0)
- {
- if (y != 0)
- {
- wynik = x / y;
- return wynik;
- }
- else return -1;
- }
- else return -2;
- }
- int main()
- {
- if (ILORAZ(4, 0) == -2)
- {
- cout << "Nie obsluguje ujemnych" << endl;
- }
- else if (ILORAZ(4, 0) == -1)
- {
- cout << "Nie dziel przez 0" << endl;
- }
- else cout << "wynik z dzielenia wynosi: " << ILORAZ(4, 2) << endl;
- if (ILORAZ(5, 3) == -2)
- {
- cout << "Nie obsluguje ujemnych" << endl;
- }
- else if (ILORAZ(5, 3) == -1)
- {
- cout << "Nie dziel przez 0" << endl;
- }
- else cout << "wynik z dzielenia wynosi: " << ILORAZ(5, 3) << endl;
- if (ILORAZ(4, -8) == -2)
- {
- cout << "Nie obsluguje ujemnych" << endl;
- }
- else if (ILORAZ(4, -8) == -1)
- {
- cout << "Nie dziel przez 0" << endl;
- }
- else cout << "wynik z dzielenia wynosi: " << ILORAZ(4, -8) << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement