Pages

Friday, 12 June 2015

Star pattern 11

Star pattern-11-program in C

Coding:

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

for(i=1;i<=n;i++)
printf("*");
s1=s;
for(i=1;i<=s;i++)
{
printf("\n");
for(j=1;j<=i;j++)
printf(" ");
for(j=1;j<=2*s1-1;j++)
printf("*");
s1--;
}
}
else
printf("\nWrong Input");
}

Output:
Please enter no of lines(>2 and odd):5
  *
 ***
*****
 ***
  *