No Global variables No goto statement No break outside switch Write a menu driven C program using functions and switch. Feel free...

90.2K

Verified Solution

Question

Programming

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.

  1. Circle
  2. Triangle
  3. 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\");
   }
   }

Answer & Explanation Solved by verified expert
4.1 Ratings (779 Votes)
Dear StudentBelow i have write the complete C program as per therequirementProgramincludefunction to calculate area of circledouble CalCircleAreadouble rdouble A 314 rreturn Afunction to calculate the area of triangledouble    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students