Advertisement
DawidBartoszek3bTI

Zadanie 6

Mar 23rd, 2020
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.80 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. float ILORAZ(float a, float b) {
  4.  if (b==0) {
  5.     return -1;
  6.  }
  7.  if (a<0 || b<0) {
  8.     return -2;
  9.  }
  10.  return a/b;
  11. }
  12.  
  13. int main(){
  14. float a,b;
  15.     a=7; b=2;
  16.         if (ILORAZ (a,b)==-1) cout<<"Nie dziel przez zero"<<endl;
  17.         else if (ILORAZ (a,b)==-2) cout<<"Nie dziel przez liczby ujemne"<<endl;
  18.         else cout<<ILORAZ(a,b)<<endl;
  19.     a=11; b=0;
  20.         if (ILORAZ (a,b)==-1) cout<<"Nie dziel przez zero"<<endl;
  21.         else if (ILORAZ (a,b)==-2) cout<<"Nie dziel przez liczby ujemne"<<endl;
  22.         else cout<<ILORAZ(a,b)<<endl;
  23.     a=14; b=-7;
  24.         if (ILORAZ (a,b)==-1) cout<<"Nie dziel przez zero"<<endl;
  25.         else if (ILORAZ (a,b)==-2) cout<<"Nie dziel przez liczby ujemne"<<endl;
  26.         else cout<<ILORAZ(a,b)<<endl;
  27. return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement