Hey Pals, here I wrote one simple code to be more readable but something is wrong when i am compile it, the problem is print out the values of f[i][j] is wrong coz is a lot of 0's
Code:
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define max 300
int
main()
{
float x[max],y[max],f[max][max],u[max][max],v[max][max],ui,xs,ys,dx;
int imax,jmax,i,j,il,it;
il=11;
it=31;
imax=41;
jmax=12;
xs=1.24;
ys=1.24;
ui=0.0;
dx=-1.0/(il-it);
for(i=il;i<=it;i++)
x[i]=(i-il)*dx;
for(i=it+1;i<=imax;i++)
x[i]=x[i-1]+(x[i-1]-x[i-2])*xs;
for(i=il-1;i>=1;i--)
x[i]=x[i+1]+(x[i+1]-x[i+2])*xs;
/*initial condition*/
for(i=1;i<=imax;i++)
{
for(j=1;j<=jmax;j++)
f[i][j]=ui*x[i];
}
/*0000000000000000000000000000000000000000000000000*/
/*=====================Velocities===========================*/
for(i=2;i<=imax-1;i++)
{
for(j=2;j<=jmax-1;j++)
u[i][j]=(f[i+1][j]-f[i-1][j])/(x[i+1]-x[i-1]);
}
/* PRINT*/
for(j=1;j<=jmax;j++)
{
for(i=1;i<=imax;i++)
printf("%f\n",f[i][j]);
}
}
iam new in c so be patient with me :-)