C program for Pascal triangle






Program for Pascal triangle in c

#include<stdio.h>
int main(){
  int line,i,j,k;
  printf("Enter the no. of lines: ");
  scanf("%d",&line);
  for(i=1;i<=line;i++){
      for(j=1;j<=line-i;j++)
           printf(" ");
      for(k=1;k<i;k++)
      printf("%d",k);
      for(k=i;k>=1;k--)
      printf("%d",k);
      printf("\n");
  }
  return 0;
}


Sample output:
Enter the no. of lines: 5
   121
  12321
 1234321
123454321




2 comments:

neo rock said...

super duper logiccccccccccccc

vijay said...

but that is not pascal triangle