﻿ C_program_for_five_egg_curves 3 (Suugaku-Dokusyuu-Juku's)
```

// Calculation Program for displaying five egg curves 2-3 (Suugaku-Dokusyuu-Juku's),
// 07 (Wed.) Oct., 2009

// file name:  egg_shaped_curve_4b.c

#include< stdio.h>

#include< math.h>

void main(void)

{

double x,y,a,b,c,dc,cmax,cmin;

int i,imax,n,nmax,j,m;

double xmax,dx;

double xx[2005],yy[10][1005];
// Take care of the upper limit of storage memory capacitance.

FILE *fp;

// Setting of the constants

a=1;

b=0.69;

c=0.8;

// Setting of the other parameters

xmax=2*a;// the maximum value of x

dx=xmax/250;// the plotting interval of x

dc=c/8;

cmax=c+2*dc+0.00001;

cmin=c-2*dc;

i=0;

// execution of calculation

for(x=0;x<=xmax+dx/10;x=x+dx)

{

i++;

n=0;

xx[i]=x;

for(c=cmin;c<=cmax;c=c+dc)

{

n++;

if(x>xmax)

{

y=0;

}

else

{

if(x>c)

{

y=b*sqrt(1-((x-c)/(c+2*(a-c)))*((x-c)/(c+2*(a-c))));

}

else

{

if(x< c)

{

y=b*sqrt(1-((x-c)/c)*((x-c)/c));

}

else

{

y=b*sqrt(1-((x-c)/(c+2*(a-c)/2))*((x-c)/(c+2*(a-c)/2)));

}

}

}

yy[n][i]=y;

printf("i=%d,n=%d,c=%f,x=%f,y=%f\n",i,n,c,x,y);

}

}

imax=i;

nmax=n;

j=0;

// writing the calculated coordinates data of the curve into a textfile

for(i=imax+1;i<=2*imax;i++)

{

j++;

m=imax-j;

xx[i]=xx[m];

for(n=1;n<=nmax;++n)

{

yy[n][i]=-yy[n][m];

}

}

fp=fopen("egg-shaped curve.txt","w");

if(fp==NULL)

{

printf("FILE OPEN ERROR\n");

}

else

{

for(i=1;i<2*imax;i++)

{

fprintf(fp,"%f,%f,%f,%f,%f,%f\n",
xx[i],yy[1][i],yy[2][i],yy[3][i],yy[4][i],yy[5][i]);

}

fflush(fp);

fclose(fp);

}

printf("end\n");

}// the end of the program

```

RETURN