#include<stdio.h>
#include<conio.h>
void main()
{
int l,i,j,k;
printf("enter number of rows in odd number");
scanf("%d",&l);
for(i=0;i<=(l/2);i++)
{
for(j=0;j<(l/2)-i;j++)
{
printf(" ");
}
for(k=0;k<(2*i)+1;k++)
{
printf("*");
}
printf("\n");
}
for(i=0;i<l/2;i++)
{
for(j=0;j<i+1;j++)
{
printf(" ");
}
for(k=0;k<l-2-(2*i);k++)
{
printf("*");
}
printf("\n");
}
getch();
}
Output
#include<stdio.h>
#include<conio.h>
void main()
{
int n, c, k;
printf("Enter number of rows\n");
scanf("%d",&n);
for ( c = 1 ; c <= n ; c++ )
{
for( k = 1 ; k <= c ; k++ )
printf("*");
printf("\n");
}
getch();
}
input 5
Output
*
**
***
****
*****
0 comments :
Post a Comment