Home › Forums › C Programming › New Method to write Pascal’s Triangle in C : Using C(i,j)
- This topic has 1 reply, 2 voices, and was last updated 12 years, 4 months ago by Anonymous.
Viewing 1 reply thread
- AuthorPosts
- July 1, 2012 at 10:06 am #2256AnonymousInactive123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100<br /><br />#include<stdio.h><br />#include<ctype.h><br />#include<conio.h><br />#include<time.h><br />#include<stdlib.h><br /><br />long unsigned int Factorial(long unsigned int Number)<br />{<br />long unsigned int Fact=0;<br />if (Number==0)<br />return (long unsigned int) 1;<br />else<br /><br />{ Fact=Number*Factorial(Number-1);<br />return Fact;<br />}<br /><br /><br /><br /><br />}<br />long unsigned int Combination(long unsigned int num1,long unsigned int num2)<br />{<br />long unsigned int Comb,num3;<br />long unsigned int Factor1, Factor2,Factor3;<br />Factor1=Factorial(num1);<br />Factor2=Factorial(num2);<br />num3=num1-num2;<br />Factor3=Factorial(num3);<br />Comb=Factor1/(Factor2*Factor3);<br /><br />return(Comb);<br /><br />}<br /><br />int main()<br />{<br /><br />long unsigned int i,j,Num=0;<br />long unsigned int **Matrix;<br />clrscr();<br />printf(" %dn " ,sizeof(long unsigned int));<br />printf("Enter Index of Square Matrix Num =: ");<br />scanf ("%lu",&Num);<br /><br /><br /><br />Matrix=(long unsigned int **) malloc(Num*Num*sizeof(long unsigned int));<br /><br />for( i=0;i<Num;i++)<br />{ for (j=0;j<Num;j++)<br />{ *(*(Matrix+i)+j)=0;<br />}<br />}<br /><br />for(i=0;i<Num;i++)<br />{ for(j=0;j<=i;j++)<br />{ printf(" %lu " , *(*(Matrix+i)+j)); }<br /><br />printf("n");<br /><br />}<br /><br /><br />for(i=0;i<Num;i=i+1)<br />{<br />for(j=0;j<=i;j=j+1)<br />{<br /><br /><br />*(*(Matrix+i)+j)=Combination(i,j);<br /><br />}<br />printf("n");<br />}<br /><br />for(i=0;i<Num;i++)<br />{<br />for(j=0;j<=i;j++)<br />{<br /><br />// printf(" n %lu %lu n",i,j);<br />printf(" %lu ",*(*(Matrix+i)+j) );<br /><br />}<br />printf("n");<br />}<br /><br /><br /><br /><br /><br />getch();<br />return(0);<br /><br />}<br /><br />
- July 24, 2012 at 11:37 am #3661AnonymousInactive
Please visit the Site http://contest.collectiva.in/Contest/ContestTraining.aspx To learn Fundamentals of C Programming online video tutorials in Tamil. It is very useful for the Beginners.
- AuthorPosts
Viewing 1 reply thread
- The forum ‘C Programming’ is closed to new topics and replies.