C program to print following square using character *

#include<stdio.h>
#include<conio.h>

void main()
{
int i,j,n;
clrscr(); //to clear the screen
printf(“Enter size of the square:”);
scanf(“%d”,&n);
for(i=0;i<n;++i)
{
printf(“n”);
for(j=0;j<n;++j)
{
if(i==0||i==n-1||j==0||j==n-1)
printf(“*”);
else
printf(” “);
}
}
getch(); //to stop the screen
}

Leave a Reply

Your email address will not be published. Required fields are marked *