you are working on a laptop you need to begin the lab bymaki

you are working on a laptop, you need to begin the lab bymaking sure the laptop is logged onto the internet. Directions are on your desktop wallpaper. In this lab exercise, we are going to practice using a selection structure to direct the behavior of the program. Procedure Begin by opening a file in nano titled Lab5.c This program is going to discern between different cases that can result from the quadratic formula, and will display different results depending on if the formula returns real, imaginary, or no roots. This program will be making use of the square root function as well as prinf and scanf statements, soinclude the appropriate clibraries. Problem description: When a 2 d order polynomial is arranged in the following form: This is described as a quadratic equation in standard form. The quadratic equation can be solved for possible inputs by applying the mathematical technique of completing the square\" for x. When is and then solving this done, the resulting is what is commonly referred to as the quadratic formula: formula bt vb our end goal with this program is to write a program that takes in the three coeffi A.B, And c. then computes and displays the solutions to the quadratic equation. Depending on the values of the coefficients, there are three possibilities: If A is zero, the denominator of the QF is equal to zero, which means the formula cannot be applied to that problem. If B is zero, the solutions to the fomula are purely imaginary. (which means they consist of a number multiplied by the square root of -1, represented by the letter i. tv4ac or X ximag imag 2a 2a.

Solution

#include <stdio.h>
#include <math.h>
int main()
{
   int a,b,c,im=0;
   printf(\"Enter the values of A,B and C separated by spaces:\");
   scanf(\"%d%d%d\",&a,&b,&c);
   if(a==0)
   {
       printf(\"This is not a quadratic equation.\ \");
       return 0;
   }
   double dis,ans;
   dis = b*b - 4*a*c;
   ans = (-1.0*b)/(2.0*a);
   if(dis==0)
   {
       printf(\"The only real solution is %lf.\ \",ans);
       return 0;
   }
   if(dis<0)
   {
       im=1;
       dis = -1*dis;
   }
   dis = sqrt(dis)/(2.0*a);
   if(im==1)
   {
       if(b==0)
       {
           printf(\"The roots are %lfi or -%lfi\ \",dis,dis);
       }
       else
       {
           printf(\"The roots are %lf+%lfi or %lf-%lfi\ \",ans,dis,ans,dis);
       }
       return 0;
   }
   printf(\"The roots are %lf or %lf\ \",ans+dis,ans-dis);

   return 0;
}

 you are working on a laptop, you need to begin the lab bymaking sure the laptop is logged onto the internet. Directions are on your desktop wallpaper. In this

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site