need help on 57 5 Write a CC program that solves a quadratic
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;
 }


