need help on 57 5 Write a CC program that solves a quadratic

need help on 5-7
5) Write a C/C+ program that solves a quadratic equation, as described by the formulas for roots 1 and 2 below. Use if -elseif loops to determine if the solutions are real or complex, ie if the discriminant is greater than or equal to zero, then roots are real and the roots are complex (ie, a real and imaginary part) when the discriminant is less than zero); then evaluate the corresponding coefficients Ar BC A** x2 B x C 0 DIS (B B-4 A c) If (DIS >m 0) Root 1 B sqrt(DIS))/(2 A) Root2 B sqrt(DIS))/ (2 A); ll you must determine what formulas and print statements needed to print out both the real and imaginary parts of the complex solutions for roots 1 and 2. After writing your program, test for following inputs: 6.) write a clc* function named DISTTthat asks the user to enter two points in (xya) (ie. P1 (x1 v1.a1) and P2 (x2,Y2,zz then carries out the following calculations (a) Distance D between the two points: (b) The amplitudes of the vectors drawn from the origin to the two points

Solution

5.

#include <iostream>
#include <cmath>
using namespace std;

int main() {

float a, b, c, x1, x2, DIS, real, imaginary;
cout << \"Enter coefficients a, b and c: \";
cin >> a >> b >> c;
DIS = b*b - 4*a*c;
  
if (DIS > 0) {
Root1 = (-b + sqrt(DIS)) / (2*a);
Root2 = (-b - sqrt(DIS)) / (2*a);
cout << \"Roots are real and different.\" << endl;
cout << \"Root1 = \" << Root1 << endl;
cout << \"Root2 = \" << Root2 << endl;
}
  
else if (DIS == 0) {
cout << \"Roots are real and same.\" << endl;
Root1 = (-b + sqrt(DIS)) / (2*a);
cout << \"Root1 = Root2 =\" << Root1 << endl;
}

else {
real = -b/(2*a);
imaginary =sqrt(-DIS)/(2*a);
cout << \"Roots are complex and different.\" << endl;
cout << \"Root1 = \" << real << \"+\" << imaginary << \"i\" << endl;
cout << \"Root2 = \" << real << \"-\" << imaginary << \"i\" << endl;
}

return 0;
}

7.

#include <iostream>
#include <cmath>
using namespace std;

int main() {

int constant_B;
double x,F,E;

cout << \"Table of values for F and E are as below: \ \";
for(x=0;x<=20; x+=0.5){
for(constant_B=50;constant_B<=300;constant_B+=50){
   F=constant_B*x;
   E=0.5*constant_B*pow(x,2);
   cout<<\"F =\" << F <<\"\\t\"<< \"E =\"<<E<<\"\ \"<<endl;
}
   }

return 0;
}

need help on 5-7 5) Write a C/C+ program that solves a quadratic equation, as described by the formulas for roots 1 and 2 below. Use if -elseif loops to determi
need help on 5-7 5) Write a C/C+ program that solves a quadratic equation, as described by the formulas for roots 1 and 2 below. Use if -elseif loops to determi

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site