Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- float iloraz (float a, float b)
- {
- float iloraz;
- if(b==0)
- {
- return -1;
- }
- else if(a>0&&b>0)
- {
- iloraz = a/b;
- return iloraz;
- }
- else
- {
- return -2;
- }
- }
- int main()
- {
- int a,b;
- float c;
- cout << "Podaj liczbe naturalna a:" << endl;
- cin >> a;
- cout << "Podaj liczbe naturalna b:" << endl;
- cin >> b;
- c=ILORAZ(a,b);
- if(c==-1)
- {
- cout << "Nie dziel przez 0!" << endl;
- }
- else if(c==-2)
- {
- cout << "Liczby naturalne sa wieksze niz 0" << endl;
- }
- else
- {
- cout << "Wynik: " << c << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement