Program to print “PASCAL TRIANGLE” - 100 Most Important C# Programs

100 Most Important C# Programs

51. Program to print “PASCAL TRIANGLE”.

Code:

#include<stdio.h>

#include<conio.h>

main()

{

int n,p=1,q,num,sp;

clrscr( );

printf(“enter the number of rows”);

scanf(“%d”,&n);

for(p=0;p<=n;p++)

{

for(sp=1;sp<=40-(3*p);sp++)

printf(“ “);

for(q=0;q<n;q++)

{

if((q==q)||(q==0))

num=1;

else

num=num*((q-q)+1)/q;

printf(“%2d”,num);

printf(“\n”);

}}

getch( );

}





All materials on the site are licensed Creative Commons Attribution-Sharealike 3.0 Unported CC BY-SA 3.0 & GNU Free Documentation License (GFDL)

If you are the copyright holder of any material contained on our site and intend to remove it, please contact our site administrator for approval.

© 2016-2025 All site design rights belong to S.Y.A.