VOOZH about

URL: https://www.geeksforgeeks.org/cpp/menu-driven-c-program-for-a-simple-calculator/

⇱ Menu Driven C++ Program for a Simple Calculator - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Menu Driven C++ Program for a Simple Calculator

Last Updated : 22 Jun, 2022

Problem Statement: Write a menu-driven program using the Switch case to calculate the following:

  1. Addition of two numbers
  2. Difference between two numbers
  3. Product of two numbers
  4. Division of two numbers
  5. HCF of two numbers
  6. LCM of two numbers

👁 Image
Examples:

Input: num1 = 5, num2 = 7, choice = 1
Output: Sum is 12

Input: num1 = 5, num2 = 7, choice = 5
Output: GCD is 1

Implementation: 

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
Article Tags: