Write a function that displays the following the menu Make a
Solution
#include <stdio.h>
 #include <math.h>
 #include <stdlib.h>
void quadratic(float a,float b,float c) //function to solve quadratic equation
 {
 float d,root1,root2;
   
 d = b * b - 4 * a * c;
   
 if(d < 0){
 printf(\"\ Roots are complex number.\ \");
printf(\"\ Roots of quadratic equation are: \");
 printf(\"%.2f%+.2fi\",-b/(2*a),sqrt(-d)/(2*a));
 printf(\", %.2f%+.2fi\",-b/(2*a),-sqrt(-d)/(2*a));
   
 }
 else if(d==0){
 printf(\"\ Both roots are equal.\ \");
root1 = -b /(2* a);
 printf(\"\ Root of quadratic equation is: %.2f \",root1);
   
 }
 else{
 printf(\"\ Roots are real numbers.\ \");
   
 root1 = ( -b + sqrt(d)) / (2* a);
 root2 = ( -b - sqrt(d)) / (2* a);
 printf(\"\ Roots of quadratic equation are: %.2f , %.2f\",root1,root2);
 }
}
void factorial(int num) //function to calculate factorial of a number
 {
 long fact;
 fact =1;
 int i;
 if (num < 0)
 printf(\"\ Number should be positive\");
for(i=1;i<=num;i++)
 fact = fact * i;
 printf(\"\ Factorial of %d =%d\",num,fact);
}
void pythagorean(int a,int b,int c) //function to check if numbers form pythagorean triplet
 {
if( (a == sqrt(b*b + c*c)) || (b == sqrt(a*a + c*c)) || (c == sqrt(a*a +b*b)))
 printf(\"\ The three numbers form a pythagorean triplet\");
 else
printf(\"\ The three numbers do not form a pythagorean triplet\");
 }
 int main(void)
 {
 int num,choice;
 int a,b,c;
 float x,y,z;
 printf(\"\ ************************************************************\");
  printf(\"\  1. Solve the quadratic equation\");
 printf(\"\  2. Find the factorial of a number\");
 printf(\"\  3. Check whether the numbers form a pythagorean triplet\");
 printf(\"\ Press 0 to quit\");
 printf(\"\ ************************************************************\ \");
 
 scanf(\"%d\",&choice);
 switch(choice)
 {
 case 1: printf(\"\ Enter the values of x,y and z in the equation\");
 scanf(\"%f %f %f\",&x,&y,&z);
 quadratic(x,y,z);
 break;
case 2: printf(\"\ Enter the number\");
 scanf(\"%d\",&num);
 factorial(num);
 break;
case 3: printf(\"\  Enter the triplet numbers\");
 scanf(\"%d %d %d\",&a,&b,&c);
 pythagorean(a,b,c);
 break;
case 0:
 break;   
 }
 }
Output


