Wednesday 25 July 2012

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
}


Related Posts Plugin for WordPress, Blogger...