Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <conio.h>
- #include <ctime>
- #include <cstdlib>
- using namespace std;
- float dziel(float liczba1, float liczba2)
- {
- return(liczba1/liczba2);
- }
- float druga_funkcja()
- {
- cout << 2 << " / " << 5 << = << dziel(2, 5) << endl; // powinno być = 0.4
- cout << 5 << " / " << 2 << = << dziel(5, 2) << endl; // powinno być = 2.5
- cout << 5 << " / " << 1 << = << dziel(5, 1) << endl; // powinno być = 5
- cout << 5d << " / " << 2 << = << dziel(5d, 2) << endl; // powinno być 0.4
- cout << 5f << " / " << 2 << = << dziel(5f, 2) << endl; // powinno być 0.4
- cout << -5 << " / " << 2 << = << dziel(-5, 2) << endl; // powinno być -0.4
- cout << 5 << " / " << -2 << = << dziel(5, -2) << endl; // powinno być = 2.5
- cout << 10 << " / " << 2 << = << dziel(10, 2) << endl; // powinno być = 5
- cout << 5 << " / " << 0 << = << dziel(5, 0) << endl; // czy funkcja wyrzuci wyjątek czy zatrzyma program
- cout << 0 << " / " << 2 << = << dziel(0, 2) << endl; // czy jest możliwe
- }
- int main()
- {
- srand( time( NULL ) );
- druga_funkcja();
- getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement