### What is wrong with my code?

Help me please! i keep on seeing this error!

cannot convert `double' to `double*' for argument `1' to `double get_fx(double*, int, double, double, double)'

here is my code.

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106`` ``````#include #include using namespace std; int input_pol(double coef[],int& Pow); double get_fx(double coef[],int Pow,double l,double x,double fx); double falsi(double, double); const int MAX = 1000; void d1(); void d2(); void d3(); void d4(); int main() { double coef[1000]; double xnew[MAX], xplus[MAX], xminus[MAX]; int imax, Pow; input_pol(coef,Pow); cout << endl; cout << "Enter first guess: "; cin >> xplus[0]; cout << endl; cout << "Enter Second guess: "; cin >> xminus[0]; cout << endl; cout << "Set maximum iteration: "; cin >> imax; for(int i = 0; i < imax; i++) { xnew[i] = falsi(xplus[i], xminus[i]); if(get_fx(xnew[i])> 0) { xplus[i+1] = xnew[i]; xminus[i+1]=xminus[i]; } else { xminus[i+1] = xnew[i]; xplus[i+1]=xplus[i]; } } cout << endl << endl; for(int i = 0; i < imax; i++) { cout.setf(ios::fixed); cout.setf(ios::showpoint); cout.precision(20); cout << xnew[i] << endl; } cout << endl << endl << endl; cout << "The Approximate root is: "; cout.setf(ios::fixed); cout.setf(ios::showpoint); cout.precision(20); cout << endl << endl << xnew[imax - 1]; cin.get(); cin.get(); return 0; } int input_pol(double coef[],int& Pow) { cout<<"Enter the highest degree in the polynomial: "; cin>>Pow; cout<=0;i--) { cout<<"Enter the coefficient of each term with thier corresponding sign."<>coef[i]; cout<=0;i--) { l+=(coef[i]*pow(x,i)); fx=l; } return fx; } double falsi(double xp, double xm) { return xp - get_fx(xp) *(xp - xm)/(get_fx(xp) -get_fx(xm)); } ``````

Last edited on
this is the problem
 ``1234`` ``````double falsi(double xp, double xm) { return xp - get_fx(xp) *(xp - xm) / (get_fx(xp) - get_fx(xm)); }``````

xp is of type double you then have get_fx(xP) the first parameter of get_fx is a double pointer* not a double. not to mention that get_fx takes more than one parameter

` if(get_fx(xnew[i])> 0)`
again get_fx takes more than one parameter
thank you for that.. do you know how to fix it? i have to submit it tomorrow. I'm so tired!
Topic archived. No new replies allowed.