segmentation fault comes in the program? please help? is there any way i can check in which part of the program is the mistake? Thanks daniweb and members...

```
//function bark_edge+main program
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
double **bark_edge(int f_size,int samp_freq);
double **transpose(double **x,int M,int N);
main()
{
int f_size=1024;
float samp_freq=44100,fcmax=samp_freq/2;
double **b_edge;
b_edge=bark_edge(f_size,samp_freq);
}
//FUNCTION-bark_edge
double **bark_edge(int f_size,int samp_freq)
{
int i=0,j=1,a=1,count=0,nrows=1024;//nrows taken as 1024 arbitrarily
float fcmax=samp_freq/2,freq_reso=fcmax/f_size;
double *band_edge,*center,**b_edge1,**b_edge;
//memory allocation-center,band_edge
center=(double*)malloc(nrows*sizeof(double));
if(center==NULL)
{
printf("out of memory\n");
return 0;
}
band_edge=(double*)malloc(nrows*sizeof(double));
if(band_edge==NULL)
{
printf("out of memory\n");
return 0;
}
//memory allocation-b_edge1
b_edge1= (double**)malloc(nrows* sizeof(double *));
if(b_edge1 == NULL)
{
printf("out of memory\n");
return 0;
}
for(i = 0; i <nrows; i++)
{
b_edge1[i] = (double*)malloc(nrows* sizeof(double));
if(b_edge1[i] == NULL)
{
printf("out of memory\n");
return 0;
}
}
while(center[i]<=fcmax)
{
i=i+1;
band_edge[i-1]=center[i-1]+a*(12.35+0.054*center[i-1]);
center[i]=(band_edge[i-1]+12.35)/0.946;
b_edge1[i-1][0]=band_edge[i-1]/freq_reso;
count++;
}
for(i=2;i<count;i+2)
{
b_edge[j][0]=b_edge1[i][0];
j++;
}
b_edge[0][0]=1;
b_edge[count][0]=f_size;
b_edge=transpose(b_edge,count/2,1);
return b_edge;
}
//FUNCTION_transpose
double **transpose(double **x,int M,int N)
{
int nrows=N,ncolumns=M,i,j;
double **y;
//memory allocation for y,to store transpose
y = (double**)malloc(nrows * sizeof(double *));
if(y == NULL)
{
printf("out of memory\n");
return 0;
}
for(i = 0; i < nrows; i++)
{
y[i] = (double*)malloc(ncolumns * sizeof(double));
if(y[i] == NULL)
{
printf("out of memory\n");
return 0;
}
}
//taking transpose
for(i=0;i<N;i++)
for(j=0;j<M;j++)
{
y[i][j]=x[j][i];
}
return y;
}
```