Tuesday, February 17, 2015

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("
");
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
}

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.