Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C exercise -Switch case Define a menu function dispMenu (defined below) which will let the user select which exercise to demo. The user can quit

C exercise -Switch case

Define a menu function dispMenu (defined below) which will let the user select which exercise to demo. The user can quit with q or Q. The user can stay within a particular exercises function until they quit with a sentinel code that you choose.

// returns menu choice 1 to n. Define n choices for now. You can change n to whatever you need it to be. int dispMenu();

Demo functions////////////////

/////////////create as a function1

#include #include

int main(){

float x,y; int n;

for(n=1;n<=5;n++){

printf("enter any decimal value: "); scanf("%f",&x); y=floor(x+.5); printf ("the round-off of %.2f is %.lf ",x,y); }return 0; }

/////////

//////////////create function 2

#include

int iseven(int number);

int main(){

int number;

printf("enter a series of integers, end with 0: ");

scanf("%d",&number); printf(" "); while (number!=0){ if (iseven(number)) printf("%d is an even number. ",number); else printf("%d is an odd number. ",number); scanf("%d",&number);} return 0; }

int iseven(int number)

{ if (number%2==0) return 1; else return 0; } ////////////creating function 3

#include

int celsius(int fCurrent); int fahrenheit(int cCurrent);

int main(){ int x; printf("celsius to fahrenheit conversion table: "); printf("celsius \t\tFahrenheit ");

for(x=0;x<=100;x++){ printf("%d\t\t%d ",x,fahrenheit(x));

} printf("Fahrenheit to celcius conversion table: "); printf("fahrenheit celcius "); for( x=32;x<=212;x++){

printf("%d\t\t%d ",x,celcius(x)); }

return 0; }

int celcius (int fCurrent){ return (int)(5.9/9.0*(fCurrent-32));}

int fahrenheit(int cCurrent){ return (int)(9.0/5.0*cCurrent+32);}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_step_2

Step: 3

blur-text-image_step3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

To solve p + 3q = 5z + tan( y - 3x)

Answered: 1 week ago