In this assignment you will write a C program to show a menu

In this assignment you will write a C program to show a menu to the user to select the function to evaluate. The menu will look like: Please select an option: a) Evaluate exponential function b) Evaluate sin function c) Evaluate cos function d) Exit The only options valid are from a to d. Any other option should display a message warning the user, and asking to The program will finish only when option d is chosen. If any of the a to c options is chosen, the program will ask the user to enter a value for x, and number of \"terms\" (t); after the values are entered, the program will display the result comparing to the value obtained using the math.h function, and the percent error(difference between your calculation and the value from the math.h function), immediately after (press any key to continue), the program will display the menu again. The C program should be submitted as a standard C source code file. You can submit your files separately or zipped together into one file. Please note that the computer program should comply with the commenting and formatting rules as has been done in class. For example, there should be a header for the whole program that gives the author\'s name, class name, date, and description. End braces should be commented, and there are alignment and indenting requirements as discussed. Please ask if you have any questions.

Solution

/*

Author\'s name   : Your_Name
Class name   : Your_Class
Date       : 10-12-2016
Description   : Your_Description

*/

#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
   float x;
   char t;
   printf(\"Please select an option:\ \");
   printf(\"a) Evalute exponential function\ \");
   printf(\"b) Evalute sin function\ \");
   printf(\"c) Evalute cos function\ \");
   printf(\"d) Exit\ \");

   do
   {
   scanf(\"%c\",&t);
   printf(\"Please enter a number x=\");
   scanf(\"%f\",&x);

       switch(t)
       {
       case \'a\':
           printf(\"Answer=\",exp(x));break;
       case \'b\':
           printf(\"Answer=\",sin(x));break;
       case \'c\':
           printf(\"Answer=\",cos(x));break;
       case \'d\':
           break;
       default:
           printf(\"Invalid value, Please try again.\");
           break;
       }
   }while(t!=\'d\');
  
   getch();
}

 In this assignment you will write a C program to show a menu to the user to select the function to evaluate. The menu will look like: Please select an option:

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site