*
* * *
* * * * *
* * *
*
C program :
#include<stdio.h>
void main()
{
int n,i,j,k,space=0;
printf("enter the number of row:\n");
scanf("%d",&n);
space=n-2;
for(i=0;i<n;i++)
{
for(j=0;j<space;j++)
{
printf(" ");
}
space--;
for(k=0;k<(2*i-1);k++)
{
printf("*");
}
printf("\n");
}
space=1;
for(i=0;i<n;i++)
{
for(j=0;j<space;j++)
{
printf(" ");
}
space++;
for(k=0;k<2*(n-i)-1;k++)
{
printf("*");
}
printf("\n");
}
output:
Enter the number of rows:
5
*
* * *
* * * * *
* * *
*
No comments:
Post a Comment