Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Database Processing Fundamentals Design And Implementation

Authors: KROENKE DAVID M.

1st Edition

8120322258, 978-8120322257

More Books

Students also viewed these Databases questions

Question

What is a living will?

Answered: 1 week ago