i was writing a programm to find the square root of a number.first i thought to find how many iteration it goes.I got stuck int he middle please help me out.Here is my code.Where did i go wrong
Code:#include <iostream>
using namespace std;
double epsilon( double , double, double );
int main (void)
{
//int n,i;
int count;
double a[count],subject,epsilon;//,newepsilon;
cout<<"Please input a postive real number:";
cin>>subject;
cout<<"Please input a postive real value for the relative accuracy epsilon:";
cin>>epsilon;
cout<<"count="<<count(subject,a[],epsilon);
double count( double subject,double x[count], double epsilon);
{ x[0]=subject/2.0;
int n=0;
int count=0;
x[n+1]=((x[n] +(subject/x[n]))/2);
newepsilon=((x[n+1]-x[n])/x[n+1]);
while(epsilon > newspilon)
{
count=count+1;
x[n+1]=((x[n] +(subject/x[n]))/2);
newepsilon=((x[n+1]-x[n])/x[n+1]);
}
return count;}
}