C++
xxxxxxxxxx
using namespace std;
int main() {
char op;
float num1, num2;
cout << "Enter operator: +, -, *, /: ";
cin >> op;
cout << "Enter two operands: ";
cin >> num1 >> num2;
switch(op) {
case '+':
cout << num1 << " + " << num2 << " = " << num1 + num2;
break;
case '-':
cout << num1 << " - " << num2 << " = " << num1 - num2;
break;
case '*':
cout << num1 << " * " << num2 << " = " << num1 * num2;
break;
case '/':
cout << num1 << " / " << num2 << " = " << num1 / num2;
break;
default:
cout << "Error! operator is not correct";
break;
}
return 0;
}
Enter operator either + or - or * or divide : - Enter two operands: 3.4 8.4 3.4 - 8.4 = -5.0
Linux - How to Install anc-api-tools
Linux - How to Install curvedns
Linux - How to Install zenmap
Python - Check if a Number is Positive, Negative or 0
C - Count Number of Digits in an Integer
C++ - Check Whether a Number is Prime or Not
C - Find Largest Number Using Dynamic Memory Allocation
C++ - Check Leap Year
Kotlin - Reverse a Number
JavaScript - Check Whether a String Starts and Ends With Certain Characters
Linux - How to Install zstd
C++ - Find Quotient and Remainder
Kotlin - Find Factorial of a Number
Python - Writing Excel (XLSX) Files
Linux - How to Install xbitmaps
Java - Reverse a Number
Kotlin - Round a Number to n Decimal Places
Java - Create Pyramid and Pattern
We have been online since 2021 and 1 millions of people around the globe have visited our website since then
More visitors every month