Perform Menu Driven Arithmetic Operation

Perform Menu Driven Operation as follows:
1. addition    2. subtraction    3. multiplication    4. division


#include<iostream.h>
#include<conio.h>

void main()
{
    int a, b;
    char oper;
    clrscr();

    cout<<"Enter two numbers :";
    cin>>a>>b;
    cout<<"Enter operation :";
    cin>>oper;

    switch(oper)
    {
        case '1':
            cout<<"Sum is :"<< a + b;
            break;

        case '2':
            cout<<"Difference is :"<< a - b;
            break;

        case '3':
            cout<<"Multiplication is :"<< a * b;
            break;

        case '4':
            cout<<"Division is :"<< a / b;
            break;

        default:
            cout<<"Such operator is not available";
    }
}
Previous Post Next Post