quiz حل الأسئلة الجامعية manage_search الأرشيف

تم الحل ✓
categoryهندسة الحاسبات schoolبكالوريوس event_available2026-07-15

السؤال

Transcribed Image Text:

Write comments in your programs. Programs with no comments will receive only PARTIAL credit. For each program that you turn in, at least the following info should be included at the top of the .c file: • Author: ⚫ Date created: Brief description of the program: - input(s): - output(s): - an algorithm (or description/relationship between inputs and outputs) Submission Instructions: Use the designated Dropbox on D2L to submit your homework. Submit only the .c files. Problem 1: Quadratic Equation Solver Write a program that computes the roots of a quadratic equation ax² + bx + c = 0, which are given by the following formulas: 21= -b+ √√b2-4ac 2a -b-√√b2-4ac 22= 2a These formulas cannot be used if the value of a = 0, or if the value b2-4ac <0 (complex roots). For the case a = 0, and 60, the solution of the equation is simply given by: For the case b2-4ac <0 the roots are complex. They have the form x = Real ± Imag. i. 21 2a 4ac-62 i, 2a 4ac-62 22 i. 2a 2a Your program should ask the user to input the coefficients a, b, c of the quadratic equation and print the corresponding solution or appropriate messages. You can use the math library function sqrt(x) to compute the square root of a number x. Sample Code Executions: Red text indicates information entered by the user Enter the coefficients of the quadratic equation 2 40 150 The roots of the quadratic are: x1 = -5.00000 x2 = -15.00000 Enter the coefficients of the quadratic equation 1 -3 5 The roots of the quadratic are x1 = 1.50000+1.65831i x2 1.50000-1.658311 Enter the coefficients of the quadratic equation 0 -3 5 There is one root at 1.66667 Enter the coefficients of the quadratic equation 0 0 6 No solution possible

check_circle الجواب — حل مفصل خطوة بخطوة

hourglass_top