Program for Simple Calculator

Following is the program for Simple Calculator using switch statements.

#include<iostream.h>
int main()
{
    char op;
    float num1, num2;
    cout << "Enter operator either + or - or * or /: ";
    cin >> op;
    cout << "\nEnter two operands: ";
    cin >> num1 >> num2;
    switch(op)
    {
        case '+':
            cout <<”\nResult is: ”<< num1+num2;
            break;

        case '-':
            cout <<”\nResult is: ”<< num1-num2;
            break;

        case '*':
            cout <<”\nResult is: ”<<num1*num2;
            break;

        case '/':
            cout <<”\nResult is: ”<<num1/num2;
            break;

        default:
            <i>// If the operator is other than +, -, * or /, error message is shown</i>
            cout<<"Error! operator is not correct";
   
            break;
    }
getch();
return 0 ;
}

Output:

Enter operator either + or - or * or / : -
Enter two operands: 3.4
8.4
Result is: -5.0