Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Complete the description of the blocks in the provided flowchart. Double click on Edit and type your answer according to this code. #include #include /

Complete the description of the blocks in the provided flowchart. Double click on Edit and type your answer according to this code.
#include
#include
/* This program finds the solutions of the quadratic equation a x^2+ b*x + c =0*/
int main()
{
/* Define and initialize the variables*/
float a,b,c;
/*Define real and imaginary parts*/
float real_part, imag_part;
float D, real_root1, real_root2;
/*Set "a" to zero*/
a=0;
/* Input the coefficients of the equation and ensure that a is not equal to zero*/
while (a==0){
printf("Specify the coefficients of the quadratic a x^2+ bx + c,
");
printf("The value of the a coefficient must be non-zero
");
/*The code will scan the input numbers*/
scanf("%f %f %f", &a, &b, &c);
}
/* Calculate the discriminant value*/
D =(b * b)-(4* a * c);
/* Write an if/else statement to check if the roots are real or complex numbers*/
if (D >=0)
{
/*Set real_root1 to calculate x1 as a real number*/
real_root1=(-b + sqrt(D))/(2* a);
/*Set real_root2 to calculate x2 as a real number*/
real_root2=(-b - sqrt(D))/(2* a);
printf("The real roots of the quadratic %.2f x^2+%.2f x +%.2f are
", a, b, c);
printf("x1=%.4f, x2=%.4f
", real_root1, real_root2);
}
else
{
/*Set real_part to calculate -b/2a*/
real_part =-b /(2* a);
/*Set imag_part to calculate the imaginary part*/
imag_part = sqrt(-D)/(2*a);
printf("The complex roots of the quadratic %.2f x^2+%.2f x +%.2f are
",a,b,c);
printf("x1=%.4f+j%.4f, x2=%.4f-j%.4f",real_part,imag_part,real_part,imag_part);
}
return 0;
}
image text in transcribed

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

Genomes Browsers And Databases Data Mining Tools For Integrated Genomic Databases

Authors: Peter Schattner

1st Edition

0521711320, 978-0521711326

More Books

Students also viewed these Databases questions