RafalSobala

zad6**

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