Need help, can not get function to return

I am trying to get number from a file and use the quad formula to get the positive value and the negative value. I think I need to pass them by reference but I am not sure what I am doing wrong.... I get the error


1>------ Build started: Project: homework4, Configuration: Debug Win32 ------
1> Homework 4.cpp
1>v:\compsci\homework4\homework4\homework4\homework 4.cpp(84): warning C4715: 'value_x_positive' : not all control paths return a value
1>v:\compsci\homework4\homework4\homework4\homework 4.cpp(120): warning C4715: 'value_x_negative' : not all control paths return a value
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========



Can someone help me on how to fix this?




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

const int MAXSIZE = 500;
double value_x_positive (int& a, int& b, int& c);
double value_x_negative (int& a, int& b, int& c);
void PrintArray(double& x_positive, double& x_negative);

int main()
{

int a[100],b[100],c[100];
int count=0, k =0;
double x_positive(10), x_negative(10);
ifstream infile;
infile.open("homework4.txt");

if(infile.fail()) {
cout << "The file did not work" << endl;
exit(1);
}


while (count < MAXSIZE && !infile.eof())
{

int k;
for (k = 0; k < 100; k ++)
{

infile>>a[k]>>b[k]>>c[k];
cout<<"a="<<a[k]<<"b="<<b[k]<<"c="<<c[k]<<endl;


PrintArray(x_positive, x_negative);


}


}


return 0;
}






double value_x_positive (int a[], int b[], int c[])

{

double x_positive,step1,step2,step3,step4;
int r;

for (r = 0; r < 100; r ++)
{
cout<<"Please enter the score" <<endl;
cin>>a[r]>>b[r]>>c[r];


step1 = pow (b[r],2.0);
step2 = (step1 - (4.0*(a[r]*c[r])));
step3 = (-b[r] + step2);
step4 = (step3 / (2*a[r]));

x_positive = step4;
return x_positive ;
}
}








double value_x_negative (int a[], int b[], int c[])

{

double x_negative,step1,step2,step3,step4;
int j;



for (j = 0; j < 100; j ++)
{

cout<<"Please enter the score" <<endl;
cin>>a[j]>>b[j]>>c[j];


step1 = pow(b[j],2.0);
step2 = (step1 - (4*(a[j]*c[j])));
step3 = (-b[j] - step2);
step4 = (step3 / (2*a[j]));


x_negative = step4;
return x_negative ;

}

}





void PrintArray(double& x_positive, double& x_negative )
{
using namespace std;
cout<<x_positive<<endl;
cout<<x_negative<<endl;

return ;
}
egative value from it
@ajc5520

To get rid of
1
2
1>v:\compsci\homework4\homework4\homework4\homework 4.cpp(84): warning C4715: 'value_x_positive' : not all control paths return a value
1>v:\compsci\homework4\homework4\homework4\homework 4.cpp(120): warning C4715: 'value_x_negative' : not all control paths return a value
move return x_negative; and return x_positive; to just above the ending right bracket of each function.
Topic archived. No new replies allowed.