clanguage07@gmail.com

clanguage07@gmail.com

Saturday, June 16, 2012

Write a C program to generate Pascal's triangle.

program:

#include<stdio.h>
#include<conio.h>

void main()
{
int bin,p,q,r,x;
clrscr();
bin=1;
q=0;

printf("Rows you want to input:");
scanf("%d",&r);

printf("\nPascal's Triangle:\n");

while(q<r)
{
for(p=40-3*q;p>0;--p)
printf(" ");
for(x=0;x<=q;++x)
{
if((x==0)||(q==0))
bin=1;
else
bin=(bin*(q-x+1))/x;
printf("%6d",bin);
}

printf("\n");
++q;
}
getch();
}

1 comment:

GET MORE INFORMATION

http://ads.qadservice.com/t?id=c2168e05-8974-4816-872a-91936ff7379d&size=1024x768&drct=true