// Program to print number 2 in C language with CBhashaGyan
#include<stdio.h>
int main()
{
int i, j;
for (i=1; i<=5; i++)
{
for(j=1; j<=5; j++)
{
if((i==5 || j!=5) || (j==1 && i==2))
printf("* "); // star and space
else if((j==5-i+1 && i!=1) || ((j==2 || j==3) && i==1))
printf("* "); //allow space after star
else
printf(" "); // double space
}
printf("\n"); //new line
}
return 0;
}
Output:
* *
* *
*
*
* * * *
No comments:
Post a Comment