`

```
#include<iostream>
#include<cmath>
#include<iomanip>
#include<fstream>
#include<string>
using namespace std;
int main()
{
const int num=10;
double a[num],b[num],c[num],disc,x1[num],x2[num],qe,x,realpart,imaginarypart;
char answer;
do
{
for (int index=0; index<num;index++)
{
cout<<"Enter coefficient of a (a>0): ";
cin>>a[index];
cout<<"Enter coefficient of b: ";
cin>>b[index];
cout<<"Enter coefficient of c: ";
cin>>c[index];
qe=a[index]*(pow(x,2))+(b[index]*x)+(c[index]);
disc=(pow(b[index],2))-(4*a[index]*c[index]);
if (disc>=0)
{
x1[index]=-(b[index]/2*a[index])+(sqrt(disc))/(2*a[index]);
x2[index]=-(b[index]/2*a[index])-(sqrt(disc))/(2*a[index]);
cout<<" Roots are real and different."<<endl;
cout<<"x1= "<<x1[index]<< endl;
cout<<"x2= "<<x2[index]<< endl;
}
else
{
realpart=-b[index]/(2*a[index]);
imaginarypart=(sqrt(-disc))/(2*a[index]);
x1[index]=realpart + imaginarypart;
x2[index]=realpart - imaginarypart;
cout<< "Roots are complex and different."<<endl;
cout<<"x1= "<< realpart << "+" << imaginarypart<< "i"<< endl;
cout<<"x2= "<< realpart << "-" << imaginarypart<< "i"<< endl;
}
cout<<"Do you want to solve for another quadratic equation?(y/n)?"<<flush;
cin>>answer;
}
}
while (answer=='y'|| answer=='Y');
cout<<setprecision(4)<<fixed;
cout<<setw(9)<<"a"<<setw(9)<<"b"<<setw(9)<<"c"<<setw(9)<<"x1"<<setw(9)<<"x2"<<endl;
for(int index=0;index<num;index++)
{
cout<<index+1<<" - "<<setw(9)<<a[index]<<setw(9)<<b[index]<<setw(9)<<c[index]<<setw(9)<<x1[index]<<setw(9)<<x2[index]<<endl;
}
ofstream outputFile;
outputFile.open("report.txt");
outputFile.close();
cout<<"Number of equation solved: "<<endl;
cout<<"The largest value of coefficients a entered:"<<a<<endl;
cout<<"The smallest value of coefficients b entered:"<<b<<endl;
cout<<"The average value of coefficients c entered:"<<c<<endl;
return 0;
}
```

`