Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In C, multi calculator with switch case case 1 n factorial calculator #include int main() { int number, i; double factorial = 1; i =

In C, multi calculator with switch case

case 1 n factorial calculator

#include

int main() {

int number, i; double factorial = 1; i = 1; while (1) { printf("Enter an integer to calculate its factorial value:"); scanf("%d", &number);

if (number < 0&&number!=-99) { printf(" Please enter a positive number! "); }

else if (number == -99) { break; } else { while (i <= number) { factorial = factorial * i; i++; } printf("%d!=%lf ", number, factorial); } }return 0; }

/************************************** case 2 polar coordinate calculator

Cartesian to polar coordinate #include #include

int main()

{ float x,y,r,theta;

const float pi=3.1415; printf("please enter the coordinates:"); scanf("%f%f",&x,&y);

r=sqrt(x*x+y*y); theta=atan(y/x); theta=theta*180/pi; printf(" cartesian cordinates %f %f:polar cordinates:%f,%f degree",x,y,r,theta); return 0; }

/******************************************** case 3 Fibonacci Sequence calculator

#include int main (){ int a=0,b=1,c,element,i,n,t1=0,t2=1,j;

printf("Please enter element number of fibonacci sequence:"); scanf("%d",&element);

if(element==1){ printf("0");}

else if(element==2){ printf("0,1"); } else if (element<=0){ printf("please enter valid integer!!!"); } else{ printf("%d,%d",a,b);

for(i=3;i<=element;i++){ int c=a+b; a=b; b=c; printf(",%d",c); } printf(" ");

c=0; for (i = 1; i <= element; i++) { for(j=1;j<=t1;j++){ printf("*");} printf(" "); int c= t1 + t2; t1=t2; t2=c; }

return 0; }

/**************************************** case 4 quit

The user can only quit the program by pressing 4.

Invalid entries will prompt the user with: print out "Invalid entry" The user will then be prompted with the menu again. You must implement the menu with a switch statement and a do-while

If the user chooses a calculation, they stay within the calculator until they choose to quit it. o For example if the user chooses n! then the program will stay within the n! calculator until the user chooses to quit the n! calculator.The menu is always returned to after the user quits from a calculator.

You must create new functions which will be called from the switch statement in main. These new functions will: o Continuously ask the user for input and call the calculator function until the user quits. o These new functions (which call the existing calculator functions) do not return anything nor do they require input arguments. For example, in the case of computing n! void nFactCalc() is the new function and it asks user for input and will call computeNfact(n). It will do this until they quit.

The menu is always returned to after the user quits from a calculator.

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_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

Handbook Of Relational Database Design

Authors: Candace C. Fleming, Barbara Von Halle

1st Edition

0201114348, 978-0201114348

More Books

Students also viewed these Databases questions

Question

please help me to solve this problem

Answered: 1 week ago