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) {
- if (b==0) {
- return -1;
- }
- if (a<0 || b<0) {
- return -2;
- }
- return a/b;
- }
- int main(){
- float a,b;
- a=7; b=2;
- if (ILORAZ (a,b)==-1) cout<<"Nie dziel przez zero"<<endl;
- else if (ILORAZ (a,b)==-2) cout<<"Nie dziel przez liczby ujemne"<<endl;
- else cout<<ILORAZ(a,b)<<endl;
- a=11; b=0;
- if (ILORAZ (a,b)==-1) cout<<"Nie dziel przez zero"<<endl;
- else if (ILORAZ (a,b)==-2) cout<<"Nie dziel przez liczby ujemne"<<endl;
- else cout<<ILORAZ(a,b)<<endl;
- a=14; b=-7;
- if (ILORAZ (a,b)==-1) cout<<"Nie dziel przez zero"<<endl;
- else if (ILORAZ (a,b)==-2) cout<<"Nie dziel przez liczby ujemne"<<endl;
- else cout<<ILORAZ(a,b)<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement