Advertisement
Guest User

Untitled

a guest
Oct 20th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. #include <iostream>
  2. #include <conio.h>
  3. #include <ctime>
  4. #include <cstdlib>
  5.  
  6. using namespace std;
  7.  
  8. float dziel(float liczba1, float liczba2)
  9. {
  10. return(liczba1/liczba2);
  11. }
  12.  
  13. float druga_funkcja()
  14. {
  15. cout << 2 << " / " << 5 << = << dziel(2, 5) << endl; // powinno być = 0.4
  16. cout << 5 << " / " << 2 << = << dziel(5, 2) << endl; // powinno być = 2.5
  17. cout << 5 << " / " << 1 << = << dziel(5, 1) << endl; // powinno być = 5
  18. cout << 5d << " / " << 2 << = << dziel(5d, 2) << endl; // powinno być 0.4
  19. cout << 5f << " / " << 2 << = << dziel(5f, 2) << endl; // powinno być 0.4
  20. cout << -5 << " / " << 2 << = << dziel(-5, 2) << endl; // powinno być -0.4
  21. cout << 5 << " / " << -2 << = << dziel(5, -2) << endl; // powinno być = 2.5
  22. cout << 10 << " / " << 2 << = << dziel(10, 2) << endl; // powinno być = 5
  23. cout << 5 << " / " << 0 << = << dziel(5, 0) << endl; // czy funkcja wyrzuci wyjątek czy zatrzyma program
  24. cout << 0 << " / " << 2 << = << dziel(0, 2) << endl; // czy jest możliwe
  25. }
  26.  
  27. int main()
  28. {
  29. srand( time( NULL ) );
  30. druga_funkcja();
  31. getch();
  32. return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement