Follow by Email

Friday, June 10, 2011

Write a c program to print Pascal triangle.

#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;
}

5 comments:

  1. Appreciation for nice Updates, I found something new and folks can get useful info about BEST ONLINE TRAINING

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete