Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

How would I create a C Code using a simple mathematical equation. The code NEEDS TO prompt users to enter variables and calculate based on

How would I create a C Code using a simple mathematical equation. The code NEEDS TO prompt users to enter variables and calculate based on the formula chosen. It also needs to be used in online compilers such as ideone and repl.it

I would like to use the midpoint formula: image text in transcribed

An example of a C Code prompt using a different math equation is as follows:

#include #include

int main() { double a, b, c, discriminant, root1, root2, realPart, imagPart; printf("Enter coefficients a, b and c: "); scanf("%lf %lf %lf", &a, &b, &c);

discriminant = b * b - 4 * a *c;

//condition for real and different roots if (discriminant > 0) { root1 = (-b + sqrt(discriminant)) / (2 * a); root2 = (-b - sqrt(discriminant)) / (2 * a); printf("root1 = %.2lf and root2 = %.2lf", root1, root2); }

//condition for real and equal roots else if (discriminant ==0) { root1 = root2 = -b / (2 * a); printf("root1 = .2%lf and root2 = .2lf;", root1); }

// if roots are not real else { realPart = -b / (2 * a); imagPart = sqrt(-discriminant) / (2 * a); printf("root1 = %.2lf+%.21lfi and root2 = %.2f-%.2fi", realPart, imagPart, realPart, imagPart); } return 0; }

M _21 +22 y1 + y2 = 22

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

Step: 3

blur-text-image

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

Larry Ellison Database Genius Of Oracle

Authors: Craig Peters

1st Edition

0766019748, 978-0766019744

More Books

Students also viewed these Databases questions