C++ – Program to Make Simple calculator in C++






Write a program and call it calc.cpp which is the basic calculator and receives three values from input via keyboard.
  • The first value as an operator (Op1) should be a char type and one of (+, -, *, /, s) characters with the following meanings:
    • ‘+’ for addition (num1 + num2)
    • ‘-’ for subtraction (num1 – num2)
    • ‘*’ for multiplication (num1 * num2)
    • ‘/’ for division (num1 / num2)
    • ‘s’ for swap
  • Program should receive another two operands (Num1, Num2) which could be float or integer.
  • The program should apply the first given operator (Op1) into the operands (Num1, Num2) and prints the relevant results with related messages in the screen.
  • Swap operator exchanges the content (swap) of two variables, for this task you are not allowed to use any further variables (You should use just two variables to swap).