i keep on getting an error and its driving me insane

This is a discussion on i keep on getting an error and its driving me insane within the C Programming forums, part of the General Programming Boards category; Code: #include <stdio.h> #include <stdlib.h> #include <math.h> int main() { double k,A,B,W,NumberOfSlices,Width,y,Area,Sum; NumberOfSlices = 1200000.0; A = 10.0; B = ...

  1. #1
    Registered User
    Join Date
    Oct 2009
    Posts
    24

    i keep on getting an error and its driving me insane

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <math.h>
    
    int main()
    {
        double k,A,B,W,NumberOfSlices,Width,y,Area,Sum;
    
        NumberOfSlices = 1200000.0;
        A              = 10.0;
        B              = 6.0;
        Width          = A / NumberOfSlices;
        k              = 0.0;
        Sum            = 0.0;
        
        while ( k < NumberOfSlices )
        {
            W = ( Width * ( k + 1 ));
            y = ( B / A ) * sqrt( A * A - W * W ) ;
            Area = y * Width;
            Sum = Sum + Area;
            k = k + 1;
        }
        printf("\n\t the area of the ellipse is %10.3f",Sum * 4);
    
        printf("\n\n");
        system("pause");
        system("cls");
    
        A              = 4.0;
        k              = 0.0;
        NumberOfSlices = 10.0;
        Sum            = 0.0;
        Width          = A / NumberOfSlices;
    
        While ( k < NumberOfSlices )
        {
            W = ( Width * ( k + 1 ));
            y = W * W;
            Area = Width * y;
            Sum = Sum + Area;
            k = k + 1;
        }
        printf("\n\t the area of a parabola at x = 4 is %10.3f",Sum);
    
        printf("\n\n\n");
    }
    it keeps on saying im missing a ; before the { that follows directly after the second while command, but i dont see how that is possible. it never needed one there before. i put one there just ot humor it and it gives me an error on the while. so any help would be appreciated

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Spot the difference:
    Code:
    While
    Code:
    while

  3. #3
    Registered User
    Join Date
    Oct 2009
    Location
    While(1)
    Posts
    377
    This code is having error dude

    Code:
        While ( k < NumberOfSlices ) // this line c/c++ have while not While
        {
            W = ( Width * ( k + 1 ));
            y = W * W;
            Area = Width * y;
            Sum = Sum + Area;
            k = k + 1;
        }

  4. #4
    Registered User
    Join Date
    Oct 2009
    Posts
    24
    ty vm

Popular pages Recent additions subscribe to a feed

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