Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- float addition(float A, float B);
- float substraction(float A, float B);
- float multiplication(float A, float B);
- float division(float A, float B);
- void main()
- {
- float Left = 0.f;
- float Right = 0.f;
- float Result = 0.f;
- char Operation = '+';
- cout << "Podaj pierwsza liczbe: ";
- cin >> Left;
- cout << endl;
- cout << "Wybierz rodzaj dzialania uzywajac znakow: +, -, * lub /." << endl << "Rodzaj dzialania: ";
- cin >> Operation;
- cout << endl;
- cout << "Podaj druga liczbe: ";
- cin >> Right;
- cout << endl;
- if (Operation == '+')
- {
- Result = addition(Left, Right);
- }
- else if (Operation == '-')
- {
- Result = substraction(Left, Right);
- }
- else if (Operation == '*')
- {
- Result = multiplication(Left, Right);
- }
- else if (Operation == '/')
- if (Right == 0)
- {
- cout << "Nie dziel cholero przez zero!" << endl;
- }
- else
- {
- Result = division(Left, Right);
- }
- if (Right != 0)
- {
- cout << "Rozwiazanie: " << Left << Operation << Right << '=' << Result << endl;
- }
- system("PAUSE");
- }
- float addition(float A, float B)
- {
- return A + B;
- }
- float substraction(float A, float B)
- {
- return A - B;
- }
- float multiplication(float A, float B)
- {
- return A * B;
- }
- float division(float A, float B)
- {
- return A / B;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement