PASCALS TRIANGLE

Edited 4 Years Ago by Dani: Promoted to code snippet

#include<stdio.h>
    #include<ctype.h>
    #include<conio.h>
    #include<time.h>
    #include<stdlib.h>
    
    long unsigned int Factorial(long unsigned int Number)
    {
       long unsigned int Fact=0;
         if (Number==0)
    	  return (long unsigned int) 1;
    	  else
    
    	      {	   Fact=Number*Factorial(Number-1);
    		   return Fact;
    	       }
    
    
    
    
     }
    long unsigned int Combination(long unsigned int num1,long unsigned int num2)
    {
           long unsigned int Comb,num3;
           long unsigned int Factor1, Factor2,Factor3;
           Factor1=Factorial(num1);
           Factor2=Factorial(num2);
           num3=num1-num2;
           Factor3=Factorial(num3);
           Comb=Factor1/(Factor2*Factor3);
    
           return(Comb);
    
    }
    
    int main()
    {
    
    long unsigned int i,j,Num=0;
    long unsigned int **Matrix;
    clrscr();
    printf(" %d\n " ,sizeof(long unsigned int));
    printf("Enter Index of Square Matrix Num =: ");
    scanf ("%lu",&Num);
    
    
    
    Matrix=(long unsigned int **) malloc(Num*Num*sizeof(long unsigned int));
    
    for( i=0;i<Num;i++)
     {  for (j=0;j<Num;j++)
    	  { *(*(Matrix+i)+j)=0;
    		  }
         }
    
           for(i=0;i<Num;i++)
    	 { for(j=0;j<=i;j++)
    	     {  printf(" %lu " , *(*(Matrix+i)+j)); }
    
    	   printf("\n");
    
    	     }
    
    
    for(i=0;i<Num;i=i+1)
    {
    for(j=0;j<=i;j=j+1)
    {
    
    
    	   *(*(Matrix+i)+j)=Combination(i,j);
    
      }
        printf("\n");
        }
    
      for(i=0;i<Num;i++)
      {
       for(j=0;j<=i;j++)
    	   {
    
    	//  printf(" \n %lu  %lu \n",i,j);
    	     printf("  %lu  ",*(*(Matrix+i)+j) );
    
    	     }
    	     printf("\n");
    	     }
    
    
    
    
    
    getch();
    return(0);
    
    }