Like Tree1Likes
  • 1 Post By stahta01

I am stuck, can somebody help me solve this problem please

This is a discussion on I am stuck, can somebody help me solve this problem please within the C Programming forums, part of the General Programming Boards category; Code: I have this erro when i try to compile: In function ‚f‚: Test.c:9: error: expected expression before ‚double‚ Test.c:9: ...

  1. #1
    Registered User
    Join Date
    Mar 2013
    Posts
    15

    I am stuck, can somebody help me solve this problem please

    Code:
    I have this erro when i try to compile:
    
    In function ‚f‚:
    Test.c:9: error: expected expression before ‚double‚
    Test.c:9: error: too few arguments to function ‚pow‚
      
    
    the source code is:------------------------>
    // it will calculate the area under the curb using the trapezoidal rule
    
    #include <stdio.h>
    #include <math.h>
    double f(int x){
            pow(double x, int 2 );
            return 0;
    }
    int main(void)
    {
            int a, b, N, width, i, sum,value, area;
            printf (" Enter the interval a an b");
            scanf ("%d\n%d", &a, &b);
            printf (" Enter the number of trapezoids you would like to use");
            scanf ("%d", &N);
            width = (b-a)/N;
            
          sum=(f(a) + f(b))/2;
            for (value = a + width; value < b; value += width)
                    sum += f(value);
            area = sum * width;
            printf (" The area under the curv is %d\n", area);
            return 0;
    }

  2. #2
    Registered User
    Join Date
    May 2009
    Posts
    2,553
    Wrong
    Code:
    pow(double x, int 2 );
    Maybe right way to call/invoke pow
    Code:
    pow(x, 2 );
    Tim S.
    Crossfire likes this.
    "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the Universe is winning." Rick Cook

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C++problem to solve
    By truetrini20 in forum C++ Programming
    Replies: 9
    Last Post: 06-29-2010, 03:19 AM
  2. Please help me to solve this IO problem.
    By nichya88 in forum C++ Programming
    Replies: 2
    Last Post: 01-19-2010, 11:15 AM
  3. How is it possible to solve this problem
    By ahmet858585 in forum C Programming
    Replies: 7
    Last Post: 05-01-2007, 12:28 PM
  4. problem solve
    By coolnarugodas in forum C Programming
    Replies: 7
    Last Post: 04-26-2005, 12:31 PM
  5. problem cant solve please help.
    By sarah in forum C Programming
    Replies: 6
    Last Post: 09-03-2001, 01:32 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21