I am getting an error C2664: 'F_Ite' : cannot convert parameter 1 from 'double *' to 'double'.Will please anybody help me from this problem.I am new in C++.

Thanks

#include<iostream>
#include<cmath>
#include<algorithm>

using namespace std; // you should not use this statement.
void F_Ite(double,double,double,double,double,double);
// never ever declare global data in C++

 //Globally Data_type Declaration & Initialization :
 double z=0.0001;
 double NR=0.01;
 int NI=11;
 double RF;

  int main(int argc, char* argv[]) // put the othe arguments for main (int argc, char* argv[]) 
{
//Result Of A Fibonacci_Search Algorithm Operation On A Given Function :
  std::cout <<"\nThe Function is ' F(x)=e^(-x)+x^2 '";
  std::cout <<"\n";
  
// declare your pointers outside of your function and pass them as parameters to F_Ite
	double *a,*b,*c,*d,*Fc,*Fd,I;

	// you could optionally initialise them before passing them to your function
	int numElement =20;

	a = new double[numElement];
	b = new double[numElement];
	c = new double[numElement];
	d = new double[numElement];
	Fc= new double[numElement];
	Fd= new double[numElement];
	
	// now call the function
	F_Ite(a,b,c,d,Fc,Fd);

	// Now you can cout your values, or do whatever with them
	// don't forget to delete them when you're done.
	// wherever you create something with 'new' you should
	// always call 'delete' when finished!
  
  //User Specify The Interval :
  std::cout << "\nGive The Initian Point :" <<"\na1 =";
  std::cin >> a[1];
  std::cout << "\nGive The Final Point :" <<"\nb1 =";
  std::cin >> b[1];
  
  
  //Find Distance Between The Starting Interval :
  I=(b[1]-a[1]);
  std::cout << "\nInterval Reduction At The Initial Iteration :"<< "\nI(1) = " << I <<"\n";


  //For Accuracy Exactness Need A Small Pertubation At The Final Interval
  std::cout <<"\nFor Accuracy At The Final Interval, Taken The Small Perturbation z :";
  std::cout <<"\nTaken z = 0.0001" << "\n";
  
  //Give The Prescribe Interval Reduction :
  std::cout <<"\nNeeded The Prescribe Interval Reduction :" <<"\nNR = 0.01 units";
  std::cout <<"\n";
  
  //Calculate The Number Of Iteration From The Given Interval Reduction :
  //By Fibonacci Series
  std::cout <<"\nAccording To The Interval Reduction";
  std::cout <<"\nThe Requring Number Of Iteration :" << "\nNI = 11 times";
  std::cout <<"\n";
  std::cout <<"\n";


  system("pause");  // this is a platform specific call. do not use this.
  


  //To Calculate The Ratio of two consecutive Fibo_Num (F(m-1)/Fm) :
  //Function (F(m-1)/Fm) Declaration :
  double R_Fibo();
  std::cout <<"\nBefore The Start Of Interval Reduction";
  std::cout << "\nThe Ratio of two consecutive Fibo_Num :"<<"\nRF = 0.618056";
  std::cout <<"\n";


  //Here The Beginnins Of Iteration Technique 
  
  //We Introduce Two Another Points For Getting Two New Interval Of Uncertainty
  //First Point 'c1' And Second Point 'd1' :
  c[1]=b[1]-(R_Fibo()*I);
  std::cout << "\nPlaced A Point c1 Within The Initial Interval :"<< c[1];
  d[1]=a[1]+(R_Fibo()*I);
  std::cout <<"\nPlaced Another Point d1 Within The Initial Interval :"<<d[1];
  std::cout <<"\n";
  std::cout <<"\n";
  
  //Showing The Starting Reduction :
  //----------------
  //----------------
  std::cout <<"At The First Iteration :\n";
  std::cout <<"The Value Of a1=" << a[1] << "\n";
  std::cout <<"The Value Of b1=" << b[1] << "\n";
  std::cout <<"The Value Of c1=" << c[1] << "\n";
  std::cout <<"The Value Of d1=" << d[1] ;
  //Function 'Fc1' at point 'c1' And Function 'Fd1' at point 'd1':
  //--------------------
  
// write a function which takes one argument and returns the value. use it here instead of explicit coding.
  Fc[1]=(exp(-c[1]))+(c[1]*c[1]);
  std::cout << "\nAt c1 The Function Value Fc1=" << Fc[1];
  //std::cout <<"\n";
  Fd[1]=(exp(-d[1]))+(d[1]*d[1]);
  std::cout << "\nAt d1 The Function Value Fd1=" << Fd[1];
  std::cout <<"\n";
  std::cout <<"\n";
  //---------------------
  //---------------------

  //system("pause");

  // this must be defined outside of main and called here explicitly.
  
  




  double In=b[NI]-a[NI];
  std::cout <<"\nThe Interval Reduction At The Final Iteration :" <<"\nI(n)= " << In;
  std::cout<<"\n";
  
  delete [] a;
  delete [] b;
  delete [] c;
  delete [] d;
  delete [] Fc;
  delete [] Fd;
  

  std::cout << std::endl;
  system("pause");
 //return 0;
}



  //Ratio of two successive terms of Fibonacci Sequence is obtained using Binet's Formula
  //Function (F(m-1)/Fm) Defination :
  double R_Fibo()
  {
  double n1=1-(sqrt((double)5));
  double n2=1+(sqrt((double)5));
  double s=(n1/n2);
  //cout << "\nsThe Value Of s = " << s <<"\n";

  double s1=(sqrt((double)5)-1)/2;
  //cout << "\nThe Value Of s1 = " << s1 <<"\n";

  double RF=s1*((1-pow(s,NI))/(1-pow(s,(NI+1))));
  
  //std::cout << "\nThe Ratio of two consecutive Fibo_Num :"<<"\nRF = " << RF <<"\n"; 
  //std::cout << RF; 

  return RF;

 } 
  

// pass values into F_Ite() function
 void F_Ite(double *a, double *b, double *c, double *d, double *Fc, double *Fd)
 {                          //F_Ite Function Start
  
  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];
		cout <<"The Value Of a" << k+1 << "=" << a[k+1] << "\n";
		b[k+1]=d[k];
		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;
		  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]);
		cout <<"The Value Of c" << k+1 << "=" << c[k+1] << "\n";
		}
		d[k+1]=c[k];
		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[10]<Fd[10])
	{
		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 Close

Recommended Answers

All 5 Replies

double *a,*b,*c,*d,*Fc,*Fd,I;

They're all pointers, so to get the contents of a pointer

float f = *a;

F_Ite( *a, *b, *c, *d, *Fc, *Fd );

It's better to avoid using system("pause");

Use cin.get(); as a replacement of system("pause"); , less typing and more portable :) !!

Check out this if you want to know why :)

double *a,*b,*c,*d,*Fc,*Fd,I;

They're all pointers, so to get the contents of a pointer

float f = *a;

F_Ite( *a, *b, *c, *d, *Fc, *Fd );

After doing float f = *a;

F_Ite( *a, *b, *c, *d, *Fc, *Fd );
I am getting two Linking error shown below

(1) error LNK2019: unresolved external symbol "void __cdecl F_Ite(double,double,double,double,double,double)" (?F_Ite@@YAXNNNNNN@Z) referenced in function _main

(2) fatal error LNK1120: 1 unresolved externals

It's better to avoid using system("pause");

Use cin.get(); as a replacement of system("pause"); , less typing and more portable :) !!

Check out this if you want to know why :)

Your suggestion i sreally good.I will obviously follow this.

Thank you very much my frnd

commented: That's the spirit :) +9

Thanks to everybody as it has been solved with all of yours suggestion.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.