Bhuvan InfoTech Android App

Download our Android App and browse Technical News, Projects, Computer Tricks more easily with lots of Interesting Features.

Tuesday, June 14, 2016

Print Pascal Triangle | C program


#include<stdio.h>

long factorial(int);

int main()
{

int i, no, c;

printf("Enter number of rows of pascal triangle?\n");

scanf("%d",&n);

for ( i = 0 ; i < no ; i++ )
{

for ( c = 0 ; c <= ( no - i - 2 ) ; c++ )

printf(" ");

for( c = 0 ; c <= i ; c++ )

printf("%ld ",factorial(i)/(factorial(c)*factorial(i-c)));

printf("\n");

}

return 0;

}




long factorial(int no)

{

int c;

long result = 1;



for( c = 1 ; c <= no ; c++ )

result = result*c;

return ( result );

}
Bhuvan Arora

No comments:

Amazing Deal !