Too few arguments on ~approx. lines 29 and 32 on fp and newton statements

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jradCnoob
    New Member
    • Nov 2013
    • 1

    #1

    Too few arguments on ~approx. lines 29 and 32 on fp and newton statements

    Too few arguments error around lines 29 and 32

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <math.h>
    double f(double a, double b, double c, double x)
    {
    return pow(x,3)+a*pow(x,2)+b*x+c;
    }
    double fp(double a, double b, double c, double x)
    {
    return 3*pow(x,2)+(2*a*x)+b+0*c;
    }
    double newton(double a, double b, double c, double x)
    {
    return x - (f(a,b,c,x)/fp(a,b,c,x));
    }
    int main()
    {
    double a,b,c,x1,x2; 
    int i;
    char *input = getenv("QUERY_STRING");
    sscanf(input, "coeff1=%lf &coeff2=%lf &coeff3=%lf &x=%lf", &a, &b, &c, &x1);
    if (fp(x1)==0.0)
    {
    printf("No convergence.\n");
    return 0;
    }
    for (i=0;i<100;i++)
    {
    x2=newton(x1);
    if (fabs(x1-x2)<= pow(10,-10)) break;
    x1=x2;
    }
    printf("iteration = %d\n", i);
    printf("x= %lf\n", x1);
    return 0;
    }
    Last edited by Niheel; Nov 21 '13, 02:23 PM. Reason: added code tags and bit of an explanation with the code
Working...