Pages

Friday, 12 June 2015

Star pattern 9

Star pattern- 9 - program in C

Coding:

#include<stdio.h>
int main()
{
int i,j,n,k;
printf("Please enter number of lines:");
scanf("%d",&n);
for(i=n,k=1;i>=1;i--,k++)
{
for(j=1;j<k;j++)
{
printf(" ");
}
for(j=2*i-1;j>=1;j--)
printf("*");

printf("\n");
}
return 0;
}

Output:
Please enter number of lines:5
*********
 *******
  *****
   ***   
    *