Menu Driven C++ Program for a Simple Calculator Last Updated : 22 Jun, 2022 Comments Improve Suggest changes Like Article Like Report Problem Statement: Write a menu-driven program using the Switch case to calculate the following: Addition of two numbersDifference between two numbersProduct of two numbersDivision of two numbersHCF of two numbersLCM of two numbers Examples: Input: num1 = 5, num2 = 7, choice = 1 Output: Sum is 12 Input: num1 = 5, num2 = 7, choice = 5 Output: GCD is 1 Implementation: CPP // C++ program to illustrate // Menu-Driven program using Switch-case #include <bits/stdc++.h> using namespace std; // Function to display the menu void menu() { cout << "Press 1 to calculate Sum of Numbers\n"; cout << "Press 2 to calculate Difference of Numbers\n"; cout << "Press 3 to calculate Product of numbers\n"; cout << "Press 4 to calculate Division of numbers\n"; cout << "Press 5 to calculate HCF of numbers\n"; cout << "Press 6 to calculate LCM of numbers\n"; cout << "Press 7 to exit\n"; } // Function to calculate and display the result void result(int choice, int a, int b) { // Display the result switch (choice) { case 1: { cout << "Sum is " << (a + b) << "\n"; break; } case 2: { cout << "Difference is " << (a - b) << "\n"; break; } case 3: { cout << "Product is " << (a * b) << "\n"; break; } case 4: { cout << "Division is " << (a / b) << "\n"; break; } case 5: { cout << "GCD is " << __gcd(a, b) << "\n"; break; } case 6: { cout << "LCM is " << ((a * b) / __gcd(a, b)) << "\n"; break; } case 7: { cout << "Thank you\n"; break; } default: printf("Wrong Input\n"); } } int main() { // Get the two numbers int a = 5, b = 7; int choice, res; // Display the menu menu(); // Enter the choice cout << "Enter your choice:\n"; choice = 1; cout << "Choice is " << choice << endl; // Display the result // according to the choice result(choice, a, b); return 0; } Output:Press 1 to calculate Sum of Numbers Press 2 to calculate Difference of Numbers Press 3 to calculate Product of numbers Press 4 to calculate Division of numbers Press 5 to calculate HCF of numbers Press 6 to calculate LCM of numbers Press 7 to exit Enter your choice: Choice is 1 Sum is 12 Time Complexity: O(n).Auxiliary Space: O(1) Comment More infoAdvertise with us Next Article Menu Driven C++ Program for a Simple Calculator S spp____ Follow Improve Article Tags : Mathematical C++ Programs Computer Science Fundamentals DSA Menu driven programs +1 More Practice Tags : Mathematical Similar Reads C++ Program to Make a Simple Calculator A simple calculator is a device used to perform basic arithmetic operations such as addition, subtraction, multiplication, and division. It makes arithmetic calculations easier and faster. In this article, we will learn how to code a simple calculator using C++.ExamplesInput: Enter an operator (+, - 3 min read Menu driven program for system control using C++ Prerequisite: Switch-case in C/C++ Problem Statement:Write a menu-driven program to control your system such as shutdown, restart, log off, manual shutdown settings, abort the shutdown, and exit, using Switch-case. Approach: The idea is to use system() in C. This function is used to invoke operating 3 min read C++ program for Complex Number Calculator Pre-Requisites: Complex Numbers, Mathematics, Object-oriented Programming This is a Complex Number Calculator which performs a lot of operations which are mentioned below, to simplify our day-to-day problems in mathematics. The implementation of this calculator is done using C++ Programming Language 15+ min read Menu-Driven program using Switch-case in C A Menu Driven program is a program that represents a menu of options to the user and different actions are performed based on different options. In this article, we will learn to write a Menu Driven program using Switch-case in C. Menu Driven Program in C The below program demonstrates an example of 2 min read C++ Program to Perform Calculations in Pure Strings Given a string of operations containing three operands for each operation "type of command", "first operand", and "second operand". Calculate all the commands given in this string format. In other words, you will be given a pure string that will ask you to perform an operation and you have to perfor 5 min read Like