February 15, 2011

C Program To Print Square Of Stars


C Program To Print Square Of Stars
Output will be like:

***
*  *
***

code:

//C Program to Print Square of Stars
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
clrscr();
for(a=1;a<=3;a++)
{
for (b=1;b<=a;b++)
{
if(a==2&&b==2)
{
printf(" ");
}
else
{
printf("*");
}
}
for(b=(3-a);b>=1;b--)
{
printf("*");
}
printf("\n");
}
getch();
}

Give comments if you have any doubts... :)

Related Posts :



2 comments:

i m not getting from which angle is this a square?????

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Related Posts with Thumbnails