C Programming Code Examples C > Pyramid Patterns Code Examples Print Pascal's triangle - Programs to display pyramid and inverted pyramid using * and digits Print Pascal's triangle - Programs to display pyramid and inverted pyramid using * and digits #include <stdio.h> int main() { int rows, coef = 1, space, x, j; printf("Enter number of rows: "); scanf("%d",&rows); for(x=0; x<rows; x++) { for(space=1; space <= rows-x; space++) printf(" "); for(j=0; j <= x; j++) { if (j==0 || x==0) coef = 1; else coef = coef*(x-j+1)/j; printf("%4d", coef); } printf("\n"); } return 0; }