Since this is C++, it's better to use std::vector, and if not Visual Studio, then use the member function .at to find errors.

And you or your little brother should really learn to indent:

Code:

using namespace std;
#include<iostream>
#include<fstream>
#include<iomanip>
#include<cmath>
void linereg(double[],double[], double[], double[], double[]);
int main()
{
double dc[4],gt[25],snr[25], b[4], a[4], r[4];
char skiplines[80];
int i,j,z=0;
ifstream indata("noisedata.txt");
for (i=0;i<=3;i++)
{
indata.getline(skiplines, 80);
}
for (i=0;i<=4;i++)
{
indata >> dc[i];
cout << dc[i] <<endl;
for (j=0;j<=4;j++)
{
indata>>gt[z]>>snr[z];
cout << gt [z] << " " << snr[z] << endl;
z++;
}
}
cout<<endl;
//cout << setw(20) << "dc(atoms/cc*10e-17)" << setw(8) << "slope" << setw(12)
//<< "intercept" << setw(12) << "r-squared" << endl;
//cout << "-------------------------------------------------" << endl;
linereg(gt, snr, a, b, r);
for(i=0;i<=4;i++){
cout << fixed << setprecision(1) << setw(12) << dc[i] << setprecision(2) << setw(15) << a[i] << setw(10) << b[i] << setw(14) << setprecision(4) << r[i] << endl;
}
system("pause");
return 0;
}
void linereg(double gt[], double snr[], double slope[], double intercept[], double rsqrd[])
{
int i, j, k=0;
double xsum=0., ysum=0., xave, yave, x2sum=0., y2sum=0., xysum=0.;
double n = 5, r[4];
for(j=0;j<5;j++){
xsum=0., ysum=0., xave, yave, x2sum=0., y2sum=0., xysum=0.;
for(i=0;i<5;i++)
{
xsum+=gt[k];
ysum+=snr[k];
x2sum+=gt[k]*gt[k];
y2sum+=snr[k]*snr[k];
xysum+=gt[k]*snr[k];
k++;
}
xave=xsum/n;
yave=ysum/n;
slope[j]=(xysum-yave*xsum)/(x2sum-xave*xsum);
cout << slope[j] << endl;
intercept[j]=yave-slope[j]*xave;
cout << intercept[j] << endl;
r[j]=(xysum-n*xave*yave)/(sqrt(x2sum-n*xave*xave)*sqrt(y2sum-n*yave*yave));
rsqrd[j]=r[j]*r[j];
cout << rsqrd[j] << endl;}
cout<<endl;
}