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... :)#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();
}
Categories:
c program
,
Special Codes
,
Star Codes
2 comments:
i m not getting from which angle is this a square?????
It is Square by stars
Post a Comment