Calculator

Report a typo

Create a C++ program that simulates a simple calculator. The program should take two numbers and an operator (+, -, *, or /) as input from the user. Perform the corresponding arithmetic operation and print the result.

Fulfill the following points while creating the calculator:

  • Division by integer 0 is not allowed. If performed, print Division by zero is not allowed.
  • Other operators are not allowed for calculations. If other operator is used other than the above four mentioned operators then print Invalid operator.

Sample Input 1:

2 0 /

Sample Output 1:

Division by zero is not allowed

Sample Input 2:

3 4 &

Sample Output 2:

Invalid operator

Sample Input 3:

3 4 +

Sample Output 3:

Result: 7

Sample Input 4:

3 4 -

Sample Output 4:

Result: -1
Write a program in C++





Create a free account to access the full topic