Advertisement
PiotrJurek

Zad6

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