#include
void main()
{
int n, c, k, space, r;
printf("Enter number of rows\n");
scanf("%d",&n);
space = 1;
r = n-1;
for( c = 1 ; c <= 2*n - 1 ; c++ )
printf("*");
printf("\n");
for ( k = 2 ; k <= n ; k++ )
{
for( c = 1 ; c <= r ; c++ )
printf("*");
for ( c = 1 ; c <= space ; c++ )
printf(" ");
space = 2*k-1;
for( c = 1 ; c <= r ; c++ )
printf("*");
r--;
printf("\n");
}
getch();
return 0;
}
--------------------------------------
output:-
Enter number of rows
7
*************
****** ******
***** *****
**** ****
*** ***
** **
* *
void main()
{
int n, c, k, space, r;
printf("Enter number of rows\n");
scanf("%d",&n);
space = 1;
r = n-1;
for( c = 1 ; c <= 2*n - 1 ; c++ )
printf("*");
printf("\n");
for ( k = 2 ; k <= n ; k++ )
{
for( c = 1 ; c <= r ; c++ )
printf("*");
for ( c = 1 ; c <= space ; c++ )
printf(" ");
space = 2*k-1;
for( c = 1 ; c <= r ; c++ )
printf("*");
r--;
printf("\n");
}
getch();
return 0;
}
--------------------------------------
output:-
Enter number of rows
7
*************
****** ******
***** *****
**** ****
*** ***
** **
* *
No comments:
Post a Comment