Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Computer Programming with Engineering Applications Assignment 2 1. (100 pts) Wri

ID: 640158 • Letter: C

Question


Computer Programming with Engineering Applications Assignment 2 1. (100 pts) Write a program that determines the roots of a quadratic equation. Given an equation of the form The roots of the equation can be computed using the formula ac Your program should read the coefficients from user and display one the following messages depending on the value of roots. . No real roots This means b-4ac 0 Tuo equal roots This means b2-4ac This means & lac-0 . Tuo diatinct roots This means bco Test your program for the following cases (a) Equation ie of the form ax 2+bt (a) Equation 1e of the forn ax 2+bx+c-0 Enter a, b, c Tro aqual roots (b) Equation is of the forn ax 2+ batc o Enter a, b, c: 1 3 1 Tuo distinct roots (e) Equation in of the fore ax 2+bxteeo Enter a, b. c No real roots The program pou subrust should be pour oun work Chealing will be reported to office of academie integrity. Bath the copier and copéce ndl be held responsible MacBook Pro 5 6 8 9

Explanation / Answer


#include <stdio.h>
#include <conio.h>
#include <math.h>

float c[3];

// following funcion determines and returns determinent of the quadratic equation
float determinent(float a, float b, float c){
   return (b * b) - (4 * a * c);
}

int main(){
   float a, b, c;
   printf("Equation is of the form ax^2+bx+c=0 ");
   printf("Enter a, b, c: ");
   scanf("%f%f%f", &a, &b, &c);
   float det = determinent(a, b, c);
   if(det > 0){
       printf("Two Dinstinct Roots ");
   }
   else if(det == 0){
       printf("Two equal roots ");
   }
   else{
       printf("No real roots ");
   }
   return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote