0% found this document useful (0 votes)
13 views2 pages

Oop 1

Uploaded by

pranilmali1131
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views2 pages

Oop 1

Uploaded by

pranilmali1131
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

#include <iostream>

using namespace std;

int main() {

double num1, num2;

char operation;

cout << "Enter first number: ";

cin >> num1;

cout << "Enter second number: ";

cin >> num2;

cout << "Enter the operation (+, -, *, /): ";

cin >> operation;

switch (operation) {

case '+':

cout << "Result: " << num1 + num2 << endl;

break;

case '-':

cout << "Result: " << num1 - num2 << endl;

break;

case '*':

cout << "Result: " << num1 * num2 << endl;

break;

case '/':

if (num2 != 0)

cout << "Result: " << num1 / num2 << endl;

else

cout << "Error: Division by zero is not allowed." << endl;

break;

default:
cout << "Invalid operation." << endl;

return 0;

You might also like