Pascal triangle in c
Pascal triangle: Number pattern develop in a triangle shape is known as pascal triangle
#include<stdio.h>
main()
{
int i,j,k,m,l=0;
printf("enter no. of rows : ");
scanf("%d",&m);
k=m;
for(i=1;i<=m;i++)
{
for(j=1;j<=k;j++)
{
printf(" ");
}
for(l=1;l<=i;l++){
printf("%d ",l);
}
printf("\n");
k=k-1;
}
return 0;
}
output :
enter no. of rows : 5
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
No. of rows may vary as your choice you provide the value of rows when computer asks to enter the no. of rows
No comments