Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- double x_1, y_1, r_1; char symbol;
- cout << "Enter first number" << "\n";
- cin >> x_1;
- cout << "Enter second number" << "\n";
- cin >> y_1;
- cout << "List of operations which you can use are +, -, *, /" << "\n" << "What operation do you want to do?" << "\n";
- cin >> symbol;
- if (symbol == '+') {
- r_1 = x_1 + y_1;
- cout << x_1 << "+" << y_1 << "=" << r_1;
- }
- else if (symbol == '-') {
- r_1 = x_1 - y_1;
- cout << x_1 << "-" << y_1 << "=" << r_1;
- }
- else if (symbol == '*') {
- r_1 = x_1 * y_1;
- cout << x_1 << "*" << y_1 << "=" << r_1;
- }
- else if (symbol == '/') {
- if (y_1 == 0) {cout << "Error";}
- else {
- r_1 = x_1 / y_1;
- cout << x_1 << "/" << y_1 << "=" << r_1 << endl;
- }
- }
- else {
- cout << "You didn't introduce operation" << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement