No Globalvariables
No gotostatement
No breakoutside switch
Write a menu driven C program using functions andswitch. Feel free to use “Empty Outlines†template fromCanvas to design the functions as needed to build the code. Makesure to submit your work through Canvas. You can show me your coderunning in class when you are done.
The program shows following menu to the user repetitively untiluser selects option 3 to exit.
- Circle
- Triangle
- Exit
Based on the selected menu option, it asks the user for thefollowing things -
- Option 1 - asks for radius of a circle and then display itsarea in square units
- Option 2 - asks for base and height of a triangle and thendisplays its area in square units.
You need to design functions such that each one accomplishes onetask only. Please ask if you have any questions or needclarification about the specifications.
Area of circle = 3.14 * radius *radius
Area of triangle = 0.5 * base * height
#include
#include
main() {
  printf(\"Please select from the following menuoptions:\n\");
  int choice, num, result, num1;
  printf(\"Press 1 for circle\n\");
  printf(\"Press 2 for triangle\n\");
  printf(\"Press 3 to exit\n\");
  choice = input();
  switch (choice) {
  case 1: {
     printf(\"Enter radius:\n\");
     num = input();
     int result = 3.14 * num *num;
     printf(\"Area of sphere=\");
     output(result);
  case 2: {
     printf(\"Enter the base of thetriangle:\n\");
     num = input();
     printf(\"Enter the height of thetriangle:\n\");
     num1 = input();
     int result = 0.5 * num1 *num;
     printf(\"The area of the trangleis:\n\");
     output(result);
  }
  case 3: {
     printf(\"Thank you for calculatingwith us\n\");
  }
  default:
     printf(\"wrong Input\n\");
  }
  }