Here, r=rows, c=coefficient, s=space, i & j are rows and columns respectively, for serial increment and decrement of proceeding pattern.
Code:
#include <stdio.h> int main()
{
int r,c=1,s,i,j;
printf(“\nEnter the numner of rows: “);
scanf(“%d”,&r);
printf(“\n”);
for(i=0; i<r; i++)
{
for(s=1; s<=r-1; s++)
printf(” “);
for(j=0; j<=i; j++)
{
if (j==0||i==0)
c=1;
else
c=c*(i-j+1)/j;
printf(“%4d”,c);
}
printf(“\n”);
}
return 0;
}
Output:
