Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

Guys help me with this?? ASAP THANKSS!!

0 votes
asked Feb 28, 2018 by Justin Apilado (440 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

2 Answers

0 votes
answered Feb 28, 2018 by anonymous
this is a simple program to run your exercice,hope that will be hopful for you

#include <stdio.h>

void main() {
    char opt;
    int num1,num2;
    printf("Enter the first Integer: ");
    scanf("%d",&num1);
    printf("Enter the second Integer: ");
    scanf("%d",&num2);
    printf("\nInput your option :\n");
    printf("(+) Addition.\n(-)  Substraction.\n(*) Multiplication.\n(/) Division.\n(E)  Exit.\n");
    scanf("%s",&opt);
    if(opt='+')
        printf("The Addition of  %d and %d is: %d\n",num1,num2,num1+num2);
        exit(0) ;
    if(opt='-')    
        printf("The Substraction of %d  and %d is: %d\n",num1,num2,num1-num2);
        exit(0) ;
    if(opt='*')  
        printf("The Multiplication of %d  and %d is: %d\n",num1,num2,num1*num2);
        exit(0) ;
    if(opt='/'){
        if(num2==0) {
          printf("The second integer is zero. Devide by zero.\n");
          exit(1) ;
        } else {
          printf("The Division of %d  and %d is : %d\n",num1,num2,num1/num2);
          exit(0) ;
        }
    }
    if(opt='E')
        printf("exit");
        exit(1) ;
}
0 votes
answered Feb 28, 2018 by anonymous
#include<iostream>
#include<conio.h>

using  namespace std;

void menu() {
    cout << "\n1 - Sum\n2 - Difference\n3 - Product\n4 - Quotient\n5 - Exit\n";
}

void main() {
    unsigned short input = 0;
    float num1 = 0.f, num2 = 0.f;

    do {
        menu();
        cout << "->";
        cin >> input;

        switch (input) {
        case 1:
            cout << "Give number 1 : ";cin >> num1;
            cout << "Give number 2 : ";cin >> num2;
            cout << num1 << '+' << num2 << "=" << (num1 + num2)<<endl;
            _getch();
            break;
        case 2:
            cout << "Give number 1 : ";cin >> num1;
            cout << "Give number 2 : ";cin >> num2;
            cout << num1 << '+' << num2 << "=" << (num1 - num2) << endl;
            _getch();
            break;
        case 3:
            cout << "Give number 1 : ";cin >> num1;
            cout << "Give number 2 : ";cin >> num2;
            cout << num1 << '+' << num2 << "=" << (num1 * num2) << endl;
            _getch();
            break;
        case 4:
            cout << "Give number 1 : ";cin >> num1;
            cout << "Give number 2 : ";cin >> num2;
            cout << num1 << '+' << num2 << "=" << (num1 / num2) << endl;
            _getch();
            break;
        case 5:
            cout << "Goodbye my friend."<<endl;
            _getch();
            break;
        default:
            cout << "No such option ! \a\a\n\n";
            break;
        }
    } while (input != 5);
}
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.
...