# Thread: finding area of ellipse

1. ## finding area of ellipse

so here is my code

Code:
```#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main()
{
double k,A,B,NumberOfSlices,Width,y,Area;

NumberOfSlices = 10.0;
Area = 0.0;
A = 10.0;
B = 6.0;
Width = A / NumberOfSlices;

while ( k < NumberOfSlices )
{
y = (B/A)*pow(A*A-(Width * ( k + 1 ) * Width * ( k + 1 ),(1.0/2.0));
Area = y * Width + Area;
k = k + 1;
}
printf("\n\t the area of the ellipse is %10.3f", Area * 4 );

printf("\n\n\n");
}```
i cant get it to give me an answer other than 0.000

the real answer is 188.4955...but that is by pi * a * b in which a&b are where the ellipse touches the x&y respectively graph axis.

but i have to calculate using the formula of (x^2/a^2) + (y^2/b^2) = 1 and Area = y * width. please help me. 2. For one, you've never initialized k. 3. Code:
```#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main()
{
double k,A,B,W,NumberOfSlices,Width,y,Area,Sum;

NumberOfSlices = 11.0;
Area = 0.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 + Area;
Sum = Sum + Area;
k = k + 1;
}
printf("\n\t the area of the ellipse is %10.3f",Sum );

printf("\n\n\n");
}```
thats the new one, but the numbers increase as # of slices increases, though it should be becoming smaller. the first with 10 slices was 285, the next, with 12 slices, was 312. and it just continues to rise. i need it to get closer and closer to 188.4955... 4. w8 think i figured it out., removing the + area part on area = 5. YAY ALLS I NEEDED NOW WAS TO PUT SUM * 4 AND ADD SOME 000 ONTO THE # OF SLICES AND YEs! wow im such an idiot for not realize it sooner. thankk you so much Popular pages Recent additions 