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
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