Advertisement
Michal_Pilarski

zad6

Mar 19th, 2020
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int a,b,c;
  6.  
  7. float iloraz(float a, float b)
  8. {
  9.     if(b==0)
  10.     {
  11.         return -1;
  12.     }
  13.     else if(a<0 || b<0)
  14.     {
  15.         return -2;
  16.  
  17.     }
  18.  
  19.     c = a/b;
  20.     return c;
  21. }
  22.  
  23.  
  24. int main()
  25. {
  26.     cout<<"podaj 2 liczby"<<endl;
  27.     cin>>a>>b;
  28.     cout << iloraz(a,b) << endl;
  29.     if(iloraz(a,b)==-1)
  30.     {
  31.         cout<<endl<<"Nie dziel przez 0";
  32.     }
  33.     else if(iloraz(a,b)==-2)
  34.     {
  35.         cout<<endl<<"Podawaj liczby naturalne";
  36.     }
  37.  
  38.     return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement