Heelpp mee constructing this in c++ pleaseee

0 votes
asked Feb 7, 2018 by Justin Apilado (390 points)
Construct a menu driven program that outputs the sum,
difference, product and quotient of 2 entered numbers. Let the
items below be the different  options:
1 - Sum
2 - Difference
3 - Product
4 - Quotient
5 - Exit

1 Answer

0 votes
answered Feb 8, 2018 by Laxaman Pal (440 points)

#include <iostream>

#include <cstdlib>

using namespace std;

int main()
{
    int ch;
    int a, b;
    float res;
    cout<<"Enter two numbers : ";
    cin>>a>>b;
    cout<<"\nEnter operation you want to perform : "<<endl;
    cout<<"\t1. Addition..."<<endl;
    cout<<"\t2. Subtraction..."<<endl;
    cout<<"\t3. Multiplication..."<<endl;
    cout<<"\t4. Division..."<<endl;
    cout<<"\t5. Exit..."<<endl;
    cout<<"Enter your choice!!!"<<endl;
    cin>>ch;
    switch(ch)
    {
        case 1: res = a+b;
                break;
        case 2: res = a-b;
                break;
        case 3: res = a*b;
                break;
        case 4: res = (float)a/b;
                break;
        case 5: cout<<"Thanks for stopping by!!!";
                exit(0);
    }
    cout<<"\n\nResult is :"<<res<<" !!!"<<endl;
    return 0;
}

Cheers yes

Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...