Question: Project Description: In this project, you will use structure in C programming to write a program to calculate the roots of a quadratic equation. Structure

Project Description:

In this project, you will use structure in C programming to write a program to calculate the roots of a quadratic equation. Structure concepts will be used in this project. Your program will prompt the user to enter the coefficients of a quadratic equation and store them in a structure variable of type coefficientsType. Then it will compute the roots of the quadratic equation and store the result in a structure variable of type rootsType. At the end your program displays the result as well as informative messages (real roots or complex roots).

Two functions are required in this program:

1-A function to compute the roots. It takes the coefficients of a quadratic equation (coefficientsType) and returns the roots (rootsType). Function prototype is: rootsType computeRoots(coefficientsType);

2-Display function: displays the roots. Function prototype is: void displayRoots(rootsType);

Two structure date types are required:

1- coefficientsType:

Three members:a,b and c(double type)represent coefficients of a quadratic equation, ax^2+bx+c=0 . Your program will check for invalid coefficients. In addition, coefficient must be a nonzero real number.

2-rootsType:

Three members: realRoots, root1, and root2 (double type)

a/ realRoots = 0, if the roots of the quadratic equation are not real. root1 is the real part of the complex roots, and root2 is the positive imaginary part of the complex roots. So the complex roots can be expressed as r1 = root1 + root2 i

r2 = root1 - root2 i

b/ realRoots = 1, if the roots of the quadratic equation are real. root1 and root2 are the two real roots of the quadratic equation.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!