Thread: program error

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

    program error

    Code:
    I am new to programming in c and my task is to write a simple program that is able to compute the area under a curb using the trapezoidal rule. I wrote the program but it will not compile, the error I m getting is:
    
     expected expression before â}â token
    project1.c:24: error: expected â;â before numeric constant
    
    and this are my codes:
    
    #include <stdio.h>
    int main(void)
    {
            int a, b, N,h,i,counter,A;
            printf(" enter the interval a and b");
            scanf("%d\n%d\n", &a, &b);
            prinf("enter the number of trapezoids you would like to use");
            scanf("%d\n", &N);
            h= (b-a)/N;
            while((h*((i*i)+(counter*counter))/N) <= N){
                    for(i=a; i<=b; i++)
                            for(counter=a; counter=b; counter++)
                    }
            A=(h*((i*i)+(counter*counter))/2);
            printf("the area under the curb from %d to %d is: %d", a, b, A);
            counter 0;
    }

  2. #2
    Registered User
    Join Date
    May 2010
    Posts
    4,633
    Look closely at the following snippet:
    Code:
            while((h*((i*i)+(counter*counter))/N) <= N){
                    for(i=a; i<=b; i++)
                            for(counter=a; counter=b; counter++)
                    }
    What is the purpose of that last loop? It appears to be missing it's body. It also looks malformed. Why are you assigning a value in the compare section.

    Also this looks more like a C question than a C++ question and should have been posted in the C forum.

    Jim

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 15
    Last Post: 11-28-2011, 11:48 AM
  2. Replies: 13
    Last Post: 11-03-2010, 12:45 PM
  3. C Program... Program or Compiler error?
    By Zemira in forum C Programming
    Replies: 13
    Last Post: 12-02-2009, 08:59 PM
  4. Replies: 18
    Last Post: 11-13-2006, 01:11 PM
  5. i'm trying to fix an error with my error messaging on my program
    By RancidWannaRiot in forum C++ Programming
    Replies: 10
    Last Post: 09-30-2003, 01:02 PM