void main()
{
int i,j,n,b,k;
clrscr();
printf("Enter the Number of Rows :");
scanf("%d",&n);
for(i=0;i<n;i++)
{
for(k=n;k>i;k--)
{
printf("* ");
}
b=1;
for(j=0;j<=i;j++)
{
if(i==0 || j==0)
{
printf("%d * ",b%10);
}
else
{
b=b*(i-j+1)/j;
printf("%d * ",b%10);
}
}
for(k=n-2;k>=i;k--)
{
printf("* ");
}
printf("\n\n");
}
//second part change in first line and reverce
for(i=n-2;i>=0;i--)
{
for(k=n;k>i;k--)
{
printf("* ");
}
b=1;
for(j=0;j<=i;j++)
{
if(i==0 || j==0)
{
printf("%d * ",b%10);
}
else
{
b=b*(i-j+1)/j;
printf("%d * ",b%10);
}
}
for(k=n-2;k>=i;k--)
{
printf("* ");
}
printf("\n\n");
}
getch();
}
Download
Generate Pattern in C
Reviewed by Unknown
on
12:17 pm
Rating:
No comments: