I was supposed to fill an nxn matrix in spiral order from 1 to n² using functions and then print its result but I don't know why my code doesn't function can anyone help please?

The principle was to create different functions, each filling the matrix at different time intervals then calling those functions in the main program which prints them in a spiral matrix.

```c

#include <stdio.h>
#include <stdlib.h>

/* initializing the array and variables for the whole program*/
int A[5][5],top,bottom,left,right;

int FillRowForward(int A[5][5],int top,int left,int right,int z)
/*function that fills the top of the matrix from left to right*/
{   left = 0;
        for(top=left,right=0;right<=4;right++)
    {
        A[top][right]=z;
        z++;

    }
    return A[top][right];
}
int FillRowBackwards(int A[5][5],int bottom,int left,int right,int z)
/*fills the lower part from  right to left*/
{   bottom =4;

    for(left=bottom,right=4;right>=0;right--)
    {
        A[left][right-1]=A[left][right]+z;
    }
    return A[left][right-1];
}

int FillColumnDownward(int A[5][5],int top,int bottom,int left,int z)
/*fills the last column from top to bottom*/
{
    left=0;
 for(top=left,bottom=4;top<=4;top++)
    {
        A[top+1][bottom]= A[top][bottom]+z;
    }
    return A[top][bottom];
}
int FillColumnUpward(int A[5][5],int top,int bottom,int left, int z)
/*fills the first column from bottop to top*/
{
    left =0;
    for(bottom=left,top=0;bottom>=1;bottom--)
    {
         A[bottom-1][top]=A[bottom][top]+z
    }
    return A[bottom][top];
}

int main()
{
    int i,j,k=1;

    while(k<5*5){
    int FillRowForward(int A[5][5],int top,int left,int right,int k);
    top++;
    int FillColumnDownward(int A[5][5],int top,int bottom,int right,int k);
    right--;
    int FillRowBackwards(int A[5][5],int bottom,int left,int right,int k);
    bottom--;
    int FillColumnUpward(int A[5][5],int top,int bottom,int left,int k);
    }
//prints the matrix
    for(i=0;i<=4;i++)
        for(j=0;j<=4;j++)
            printf("%d",A[i][j]);

    return 0;
}

```