Menu-Driven program using Switch-case in C Last Updated : 21 Jul, 2023 Comments Improve Suggest changes Like Article Like Report 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 a Menu-Driven program using a Switch case to calculate: Area of a circleArea of squareArea of sphere C // C program to illustrate Menu-Driven program using // Switch-case #include <stdio.h> // Function prototypes int input(); void output(float); // driver code int main() { float result; int choice, num; // printing menu printf("Press 1 to calculate area of circle\n"); printf("Press 2 to calculate area of square\n"); printf("Press 3 to calculate area of sphere\n"); printf("Enter your choice:\n"); // taking input choice = input(); // switch statement to print output according to the // choice switch (choice) { case 1: { printf("Enter radius:\n"); num = input(); result = 3.14 * num * num; printf("Area of sphere="); output(result); break; } case 2: { printf("Enter side of square:\n"); num = input(); result = num * num; printf("Area of square="); output(result); break; } case 3: { printf("Enter radius:\n"); num = input(); result = 4 * (3.14 * num * num); printf("Area of sphere="); output(result); break; } default: printf("wrong Input\n"); } return 0; } // function to take input int input() { int number; scanf("%d", &number); return (number); } // function to print output void output(float number) { printf("%f", number); } Output Press 1 to calculate area of circle Press 2 to calculate area of square Press 3 to calculate area of sphere Enter your choice: 1 Enter radius: 5 Area of circle=78.5Complexity Analysis Time Complexity: O(1)Auxiliary Space: O(1) Related ArticlesSwitch Case in CInteresting facts about switch statement in COutput of C programs | Set 30 (Switch Case)Using range in switch case in C/C++ Comment More infoAdvertise with us Next Article Menu-Driven program using Switch-case in C N NishuAggarwal Follow Improve Article Tags : Misc Technical Scripter C Programs C++ Programs Computer Science Fundamentals cpp-switch Menu driven programs +3 More Practice Tags : Misc Similar Reads 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 Menu driven program for Voting System In this article, we will write a menu-driven program to implement the Voting System. The program must contain the following properties: Cast votes.Display the count of votes of each candidate.Display the name of the candidate who has the most votes. Approach: Follow the steps below to solve the prob 3 min read Menu Driven C++ Program for a Simple Calculator 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 In 3 min read How to Write a Command Line Program in C? In C, we can provide arguments to a program while running it from the command line interface. These arguments are called command-line arguments. In this article, we will learn how to write a command line program in C. How to Write a Command Line Program in C? Command line arguments are passed to the 2 min read C program to print name pattern The printing of patterns is the most common and interesting problem. This C program prompts users to input their names and transform each letter of the name into a visually appealing big star pattern. For Example, Input: NAME Output: * * **** * * ****** ** * * * ** ** * * * * ****** * ** * **** * ** 5 min read Like