JakubKaczmarek_123

zadanie 10

Jan 29th, 2021
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3. using namespace std;
  4. float ILORAZ(float a, float b);
  5. int main(){
  6. cout << "wprowadz 2 liczby" << endl;
  7. int a, b;
  8. cin >> a >> b;
  9. if (ILORAZ(a,b) == -1) cout << "Nie dziel przez 0" << endl;
  10. else if (ILORAZ(a, b) == -2) cout << "Nie wprowadzaj liczb ujemnych" << endl;
  11. else cout << "wynik to: " << ILORAZ(a,b) << endl;
  12. }
  13. float ILORAZ(float a, float b){
  14.     if (b == 0) return -1;
  15.     else if (a < 0 || b < 0) return -2;
  16.     else return a/b;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment