Pages

Friday, 12 June 2015

Star pattern 10

Star pattern 10-program in C

Coding:

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

for(j=1;j<=i;j++)
printf("*");
for(j=1;j<=s;j++)
printf(" ");
for(j=1;j<=i;j++)
printf("*");
s=s-2;
printf("\n");
}
for(i=1;i<=2*n+2;i++)
printf("*");
}

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