Question 2) Write a user defined function called AdvancedMenu that simulates a menu with options the user can select. The function takes no arguments and does not return anything. The menu has the following options. 1. Blue Button Pressed 2. Green Button Pressed 3. Red Button Pressed 4. Yellow Button Pressed 5. Exit The user will select one of the four options and the program will display the option selected. If the user selects options 1-4, the program will ask the user to enter another option. If the user selects option 5, the program will not loop again. Hint: Use the switch statement and while loop.
Q in picture
**C
***PROVIDE COMMENTS
![Question 2) Write a user defined function called AdvancedMenu that simulates a menu with
options the user can select. The function takes no arguments and does not return anything. The
menu has the following options.
1. Blue Button Pressed
2. Green Button Pressed
3. Red Button Pressed
4. Yellow Button Pressed
5. Exit
The user will select one of the four options and the program will display the option selected. If
the user selects options 1-4, the program will ask the user to enter another option. If the user
selects option 5, the program will not loop again. Hint: Use the switch statement and while loop.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F778ebef2-39f8-4792-902a-c383666adfe6%2Fd5b626ce-ae55-4c56-ab62-cdc1f8e61dcf%2F4z74gj_processed.jpeg&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
For defining a function we have to look at the syntax of the function, and other syntax used in the code to solve the problem in the c language.
function declration:
syntax:
return_type function_name(parameter list separate by comma); |
The parameter list is optional
calling function:
To run a particular function we have to call it.
syntax:
function_name(parameter list separated by comma); |
The parameter list is depending on your declared function's parameter list.
initializing function:
To initializing function just write code in the curly braces
syntax:
return_type function_name(parameter list separated by comma){ // write your code } |
Note: we can initialize the function at declaring time also.
While loop:
Syntax:
while(condition){ // statement } |
It will execute its body's statement until the condition will not give a false result.
Switch statement:
Syntax:
switch(input){ } |
The switch is checking the matching value of the variable to the case and if it matches then execute that case statement block if the case value and variable value will not match then execute the default case's statement block.
Printing statement:
To printing a statement, we can use printf() method.
Syntax:
printf("statement"); |
Reading a value from user:
To reading data from users, we can use scanf() method.
Syntax:
scanf("%data_type_character", &variable_name); |
Step by step
Solved in 3 steps with 2 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)