﻿ C program for one round length of an egg shaped curve
```
// Calculation Program for one round length of an egg shaped curve, 08 (Tues.) Dec., 2009

// egg equation: (x*x+y*y)**2=a*(x**3)+(a-b)*x*(y**2),
// The case that a=4 and b=3.2 (or, a=1 and b=0.8) may be the nearest shape to an actual egg.

// The general condition needs b<=a, and in the case of b=0, the curve is led to a circle.

// file name: round.c

#include< stdio.h>
#include< math.h>

void main(void)
{
double a,b,x,dx,dydx1,dydx2,dydx,xmax,l,dl,pi;

// Setting of the constants
for(;;)
{
printf("Input of constant a; a= ? ");
scanf("%lf",&a);
if(a>0)
{
break;
}
else
{
printf("Please input the value of a after correcting a as a>0.\n");
}
}
for(;;)
{
printf("Input of constant b; b= ? ");
scanf("%lf",&b);
if(b>=0&&b<=a)
{
break;
}
else
{
printf("Pleease input the value of b after correcting b as 0< b < a or b=0 or b=a.\n");
}
}

printf("\n");

pi=3.1415927;
xmax=a;// the maximum value of x
dx=xmax/1000000;

// execution of calculation
if(b==0)
{
l=pi*a;
}
else
{
for(x=0.12*dx;x<=xmax;x=x+dx)
{
dydx1=(1/(2.0*sqrt(2.0)))*sqrt((a-b-2.0*x+sqrt(4.0*b*x+(a-b)*(a-b)))/x);
dydx2=(sqrt(x/2.0))*((b/sqrt(4.0*b*x+(a-b)*(a-b))-1)/sqrt(a-b-2.0*x+sqrt(4.0*b*x+(a-b)*(a-b))));
dydx=dydx1+dydx2;

dl=sqrt(1.0+dydx*dydx)*dx;
l=l+dl;
}
l=2.0*l;
}

printf("one round length of the egg shaped curve; L=%lf\n",l);
printf("\n");

printf("end\n");
}// the end of the program

```

RETURN