#include <iostream>
int main() 
{
    char o;
    float num1,num2;
    cout<<"Select an operator either + or - or * or /     :\n";
    cin>>o;
    cout<<"Enter two operands: ";
    cin>>num1>>num2;
    
    switch(o) {
        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:
            
            /* If operator is other than +, -, * or /, error message is shown */
            printf("Error! operator is not correct");
            break;
    }
    
    return 0;
}
INPUT
Select an operator either + or - or * or / : +
Enter two operands : 45
35
OUTPUT
45 + 35 = 80

Leave a Reply

Subscribe to Posts | Subscribe to Comments

All Notes on BCA

All Notes  on BCA
BCA all subjects notes

Total Pageviews

Translate

Powered by Blogger.

Copyright © All Notes on BCA