Pascal's triangle in C language | C Program to create Pascal's triangle | Pascal's triangle in C
#includemain() { int i,j,k[50],l[50][50],m; printf("Enter the number of rows."); scanf("%d",&m); for(i=1;i<=m;i++) { for(j=0;j<(m-i);j++) printf(" "); for(j=0;j<i;j++) { k[0]=1; if(j==i-1) k[j]=1; l[i][j]=k[j]; k[j+1]=l[i-1][j]+l[i-1][j+1]; printf("%5d ",k[j]); } printf("\n"); } }
No comments:
Post a Comment