Home Forums C Programming New Method to write Pascal’s Triangle in C : Using C(i,j)

Viewing 1 reply thread
  • Author
    Posts
    • #2256
      Anonymous
      Inactive


      #include
      #include
      #include
      #include
      #include

      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(" %dn " ,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 { for (j=0;j { *(*(Matrix+i)+j)=0;
      }
      }

      for(i=0;i { for(j=0;j<=i;j++)
      { printf(" %lu " , *(*(Matrix+i)+j)); }

      printf("n");

      }


      for(i=0;i {
      for(j=0;j<=i;j=j+1)
      {


      *(*(Matrix+i)+j)=Combination(i,j);

      }
      printf("n");
      }

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

      // printf(" n %lu %lu n",i,j);
      printf(" %lu ",*(*(Matrix+i)+j) );

      }
      printf("n");
      }





      getch();
      return(0);

      }

    • #3661
      Anonymous
      Inactive

      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.

Viewing 1 reply thread
  • The forum ‘C Programming’ is closed to new topics and replies.