Menu-Driven program using Switch-case in C Last Updated : 21 Jul, 2023 Summarize Comments Improve Suggest changes Share 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 SQL Commands | DDL, DQL, DML, DCL and TCL Commands SQL commands are crucial for managing databases effectively. These commands are divided into categories such as Data Definition Language (DDL), Data Manipulation Language (DML), Data Control Language (DCL), Data Query Language (DQL), and Transaction Control Language (TCL). In this article, we will e 7 min read TCP/IP Model The TCP/IP model is a framework that is used to model the communication in a network. It is mainly a collection of network protocols and organization of these protocols in different layers for modeling the network.It has four layers, Application, Transport, Network/Internet and Network Access.While 7 min read Basics of Computer Networking A computer network is a collection of interconnected devices that share resources and information. These devices can include computers, servers, printers, and other hardware. Networks allow for the efficient exchange of data, enabling various applications such as email, file sharing, and internet br 14 min read Types of Operating Systems Operating Systems can be categorized according to different criteria like whether an operating system is for mobile devices (examples Android and iOS) or desktop (examples Windows and Linux). Here, we are going to classify based on functionalities an operating system provides.8 Main Operating System 11 min read Java Programs - Java Programming Examples In this article, we will learn and prepare for Interviews using Java Programming Examples. From basic Java programs like the Fibonacci series, Prime numbers, Factorial numbers, and Palindrome numbers to advanced Java programs.Java is one of the most popular programming languages today because of its 8 min read Unified Modeling Language (UML) Diagrams Unified Modeling Language (UML) is a general-purpose modeling language. The main aim of UML is to define a standard way to visualize the way a system has been designed. It is quite similar to blueprints used in other fields of engineering. UML is not a programming language, it is rather a visual lan 14 min read Second Largest Element in an Array Given an array of positive integers arr[] of size n, the task is to find second largest distinct element in the array.Note: If the second largest element does not exist, return -1. Examples:Input: arr[] = [12, 35, 1, 10, 34, 1]Output: 34Explanation: The largest element of the array is 35 and the sec 14 min read Python Lists In Python, a list is a built-in dynamic sized array (automatically grows and shrinks). We can store all types of items (including another list) in a list. A list may contain mixed type of items, this is possible because a list mainly stores references at contiguous locations and actual items maybe s 6 min read Introduction to Java Java is a high-level, object-oriented programming language developed by Sun Microsystems in 1995. It is platform-independent, which means we can write code once and run it anywhere using the Java Virtual Machine (JVM). Java is mostly used for building desktop applications, web applications, Android 4 min read f-strings in Python Python offers a powerful feature called f-strings (formatted string literals) to simplify string formatting and interpolation. f-strings is introduced in Python 3.6 it provides a concise and intuitive way to embed expressions and variables directly into strings. The idea behind f-strings is to make 5 min read Like