Cross pattern program in C

Question:
Cross pattern program in C. Write a program to print the x-cross pattern for odd length. Must write this pattern program in C.
Pattern program logic:
- Get the odd length input from the user.
- Then insert the characters from top to bottom diagonally.
- And insert the characters from bottom to top also in a diagonal position.
- Then print the pattern.
Algorithm:
- Get the input string from the user.
- Then checks the diagonal position of the array and insert into it from top to bottom.
- And then checks the diagonal position from bottom to top to insert the string.
- At last, prints the array to display pattern.
Program:
[code lang=”c”]
include<stdio.h>
void main()
{
int i,j,n,x,y,m=0;
char a[20],c[10][10];
clrscr();
printf("enter the word with lenth odd:");
gets(a);
n=strlen(a);
for(i=0;i<n;i++) \\insert into array from top to bottom
{
for(j=0;j<n;j++)
{
if(i==j)\\ assign values to array only when i&j are equal otherwise prints null
{
c[i][j]=a[m];
m++;
}
else
{
c[i][j]=’\0’;
}
}
}
i=n-1;
m=0;
for(j=0;j<n;j++)\\insert into array from bottom to top
{
c[i][j]=a[m];
i–;
m++;
}
for(i=0;i<n;i++)\\prints the cross word
{
for(j=0;j<n;j++)
{
printf("%c",c[i][j]);
}
printf("\n");
}
getch();
}
[/code]