c programming

Summary of Quadratic Equation Activity

Save Time On Research and Writing
Hire a Pro to Write You a 100% Plagiarism-Free Paper.
Get My Paper

Main Program

• if 3 numbers provided on command line
◦ convert and assign coefficient a
◦ convert and assign coefficient b
◦ convert and assign coefficient c
◦ if a is zero

▪ if b is zero
• display error message (degenerate equation)

▪ otherwise
• solve linear equation (call solve_linear and send b,c)

Save Time On Research and Writing
Hire a Pro to Write You a 100% Plagiarism-Free Paper.
Get My Paper

◦ otherwise
▪ solve quadratic equation (call solve_quad and send a,b,c)

• otherwise
◦ display error message (must provide 3 coefficients on command line)

solve_linear

• calculate x = – c / b
Hint: you may need to use a cast to handle integer division

• print x

solve_quad

• if b2 – 4ac < 0 ◦ solve for 2 complex solutions (call solve_complex and send a,b,c)

• otherwise
◦ solve for 2 real solutions (call solve_real and send a,b,c)

solve_real

• calculate x1
Hint: x1 = (-b + sqrt(b*b-4*a*c))/(2*a);

• calculate x2
• print x1 and x2

solve_complex

• calculate real part of solution
Hint: x_real = -b/2a

• calculate imaginary part of solution
Hint: x_imag= sqrt(b2 – 4ac)/2a

• print the real part and imaginary parts separated by a plus sign and followed by the letter i
Hint: printf(“%f + %fi\n”, x_real, x_imag);

• print the real part and imaginary parts separated by a minus sign and followed by the letter i

Computer Programming II

Quadratic Equation Assignment

The purposes of this assignment include: passing of parameters, and command line parameters.
You are to write a program to solve quadratic equations in all their possibilities (real or complex
roots, or even degenerate equations). Your program should be invoked by the command:

solvequad a b c

where a, b, and c are coefficients. The solution should print on stdout.

If the solution is complex, the output should consist of a pair of expressions such as “2 + 3i”
and “2 – 3i”. Other cases will result in either two real numbers being printed, a single real
number, or perhaps just a message.

You must use separate compilation.

Calculate your order
Pages (275 words)
Standard price: $0.00
Client Reviews
4.9
Sitejabber
4.6
Trustpilot
4.8
Our Guarantees
100% Confidentiality
Information about customers is confidential and never disclosed to third parties.
Original Writing
We complete all papers from scratch. You can get a plagiarism report.
Timely Delivery
No missed deadlines – 97% of assignments are completed in time.
Money Back
If you're confident that a writer didn't follow your order details, ask for a refund.

Calculate the price of your order

You will get a personal manager and a discount.
We'll send you the first draft for approval by at
Total price:
$0.00
Power up Your Academic Success with the
Team of Professionals. We’ve Got Your Back.
Power up Your Study Success with Experts We’ve Got Your Back.

Order your essay today and save 30% with the discount code ESSAYHELP