# C++ error C4716: 'F_Ite' : must return a value

Discussion in 'Meet and Greet' started by sdmahapatra, Jun 16, 2009.

1. ### sdmahapatraNew Member

Joined:
Jun 16, 2009
Messages:
12
0
Trophy Points:
0
Hi all,I am a new coder in C++ and have found "error C4716: 'F_Ite' : must return a value".
I want to return all the value of a,b,c,Fc,Fd to the main function at each iteration at a time.

Thanks

Code:
```double F_Ite()
{                      //F_Ite Function Start
//Locally Data_type Declaration And Initialization :
int numElement =20;
double *a,*b,*c,*d,*Fc,*Fd;
a = new double[numElement];
b = new double[numElement];
c = new double[numElement];
d = new double[numElement];
Fc= new double[numElement];
Fd= new double[numElement];

for(int k=1;k<(NI-1);k++)
{                        //Main 'for' Loop Start
std::cout <<"\n";
system("pause");
std::cout <<"\n";
std::cout <<"At The "<<k+1<<" Iteration :\n";

if(Fc[k]<Fd[k])
{                     //Outer 'if' Start
a[k+1]=a[k];
std::cout <<"The Value Of a" << k+1 << "=" << a[k+1] << "\n";
b[k+1]=d[k];
std::cout <<"The Value Of b" << k+1 << "=" << b[k+1] << "\n";
//c[k+1]=b[k+1]-(0.618034*((1-pow(-0.381966,NI-k))/(1-pow(-0.381966,NI-k+1))))*(b[k+1]-a[k+1]);
//cout <<"The Value Of c" << k+1 << "=" << c[k+1] << "\n";
if(k==(NI-1))
{
c[k+1]=c[k+1]+z;
std::cout <<"The Value Of c" << k+1 << "=" << c[k+1] << "\n";
}
else
{
c[k+1]=b[k+1]-(0.618034*((1-pow(-0.381966,NI-k))/(1-pow(-0.381966,NI-k+1))))*(b[k+1]-a[k+1]);
std::cout <<"The Value Of c" << k+1 << "=" << c[k+1] << "\n";
}
d[k+1]=c[k];
std::cout <<"The Value Of d" << k+1 << "=" << d[k+1] << "\n";

Fc[k+1]=(exp(-c[k+1]))+(c[k+1]*c[k+1]);
std::cout <<"The Value Of Fc" << k+1 << "=" << Fc[k+1] << "\n";
//std::cout <<"The Value Of Fc" << k+1 << "=" << Fc[k] << "\n";

Fd[k+1]=Fc[k];
//std::cout <<"The Value Of Fd" << k+1 << "=" << Fc[k] << "\n";
std::cout <<"The Value Of Fd" << k+1 << "=" << Fd[k+1] << "\n";

}                        //Outer 'if' Close
else
{                     //Outer 'else' Start
a[k+1]=c[k];
std::cout <<"The Value Of a" << k+1 << "=" << a[k+1] << "\n";
b[k+1]=b[k];
std::cout <<"The Value Of b" << k+1 << "=" << b[k+1] << "\n";
c[k+1]=d[k];
std::cout <<"The Value Of c" << k+1 << "=" << c[k+1] << "\n";
//d[k+1]=a[k+1]+((0.618034)*((1-pow((-0.381966),(NI-k)))/(1-pow((-0.381966),(NI-k+1)))))*(b[k+1]-a[k+1]);
//std::cout <<"The Value Of d" << k+1 << "=" << d[k+1] << "\n";

if(k==(NI-1))
{
d[k+1]=d[k+1]+z;
std::cout <<"The Value Of d" << k+1 << "=" << d[k+1] << "\n";
}

else
{
d[k+1]=a[k+1]+((0.618034)*((1-pow((-0.381966),(NI-k)))/(1-pow((-0.381966),(NI-k+1)))))*(b[k+1]-a[k+1]);
std::cout <<"The Value Of d" << k+1 << "=" << d[k+1] << "\n";
}

Fc[k+1]=Fd[k];
//std::cout <<"The Value Of Fc" << k+1 << "=" << Fd[k] << "\n";
std::cout <<"The Value Of Fc" << k+1 << "=" << Fc[k+1] << "\n";
Fd[k+1]=(exp(-d[k+1]))+(d[k+1]*d[k+1]);
std::cout <<"The Value Of Fd" << k+1 << "=" << Fd[k+1] << "\n";
//std::cout <<"The Value Of Fd" << k+1 << "=" << Fd[k] << "\n";

}                        //Outer 'else' Close
}                    //Main 'for' Loop Close

//Another 'if' Condition Start But Within The 'for' Loop
if(Fc<Fd)
{
std::cout <<"\n";
std::cout <<"\nAt Final Iteration :\n";
a[NI]=a[NI-1];
b[NI]=d[NI-1];
std::cout <<"The Value Of a11 =" << a[NI] << "\n";
std::cout <<"The Value Of b11 =" << b[NI] << "\n";
}
else
{
a[NI]=c[NI-1];
b[NI]=b[NI-1];
std::cout <<"The Value Of a11 =" << a[NI] << "\n";
std::cout <<"The Value Of b11 =" << b[NI] << "\n";
}

}                   //F_Ite Function End
```

Last edited by a moderator: Jun 16, 2009