Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The Homework 1 topic is the creation of a C language program to calculate and present the two solutions of the following quadratic equation: a
The Homework topic is the creation of a language program to calculate and present the two
solutions of the following quadratic equation:
where the coefficients are real numbers with
It is a fact that the solutions are either real numbers or complex conjugate numbers,
depending on the value of the discriminant,
Specifically,
If the discriminant satisfies then the quadratic roots are real numbers, given
by
else, the roots are complex conjugate numbers, given by
Real Imag
Real Imag
A C language code is provided but it's incomplete. There are gaps to be completed in order to
run correctly and to provide the correct answers. The Homework assignment consists of tasks
as detailed below:
Task points: Provide the pseudocode that is relevant to this programming task
refer to Fig.
Task points: Complete the flowchart that is relevant to this programming task
refer to Fig.
Task points: Complete the gaps in the provided code using the correct syntax
and debug your code so that it runs correctly.
Task points: Test your code using the provided test cases.
#include stdioh
#include mathh
This program finds the solutions of the quadratic equation
int main
Define and initialize the variables
float D realroot realroot realpart, imagpart;
Input the coefficients of the equation and ensure that a is not equal to zero
while
printfSpecify the coefficients of the quadratic a :
;
printfThe value of the a coefficient must be nonzero";
Calculate the discriminant value
D
Write an ifelse statement to check if the roots are real or complex numbers
if
realroot;
realroot
printfThe real roots of the ;
printf;
else
realpart
imagpart sqrtDa;
printfThe complex roots of the quadratic are
;
printfx realpart,imagpart,realpart,imagpart:
return ;
In line of the code, write an appropriate command to define the variables of the
coefficients and c as float variables. point
In line initialize the variable to be equal to zero. point
In line specify the correct condition for the while loop. If the condition is satisfied then the loop continues to run. point
In line write a command to receive numerical values and assign them to the
coefficients and point
In line complete the numerical expression for the discriminant value point
In line specify the condition of the ifelse statement so that the first part of the ifelse statement produces the real roots and the second part of the ifelse statement produces the complex roots. point
In line write the numerical expression so that the code can calculate the second real root. point
In lines write appropriate printf commands to obtain the following output when the code runs correctly with input values c
The real roots the quadratic are
In line write the correct numerical expression for the real part of the complex roots.
point
Output:
If you enter the values c the should produce the following result,
The real roots the quadratic are
If you enter the values c the code should produce the following result,
Submit your completed code.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started