WAP to print pattern like " * *** ****** *******..... ".

/*C program to print pattern like that "* *** ***** ....."*/
#include <stdio.h>
#include <conio.h>
void main()
{
int row, a, b, x;
printf("Enter the number of rows in pyramid of stars you wish to see= ");
scanf("%d",&b);
x=b;
for(row=1;row<=b;row++ )
{
for(a=1;a<x;a++ )
printf(" ");
x--;
for(a=1;a<=2*row-1;a++ )
printf("*");
printf("\n");
}
getch();
}

Expected Output:
Enter the number of rows in pyramid of stars you wish to see=5
       *
     ***
   *****
 *******
*********

Post a Comment

Previous Post Next Post