Wednesday, 21 March 2012

C program to print Pascal Triangle programme


/* Pascal triangle in c*/

#include<stdio.h>
int main()
 {
    int line,a,b,c;
    printf("Enter the no. of lines: ");
    scanf("%d",&line);
    for(a=1;a<=line;a++)
       {
           for(b=1;b<=line-a;b++)
           printf(" ");
          for(c=1;c<a;c++)
          printf( "%d" ,c);
         for(c=a;c>=1;c--)
       
 printf( "%d" ,c);
         printf("\n");
        }//end of first loop
 }//end of main

/*output*/
       1
     121
  12321
 1234321
123454321


No comments:

Post a Comment

Compiler for C,C++ and Python {paste your programme to see the output}