Logo 
Search:

C Programming Articles

Submit Article
Home » Articles » C Programming » Mathematics ProgramRSS Feeds

EVALUATION OF BINOMIAL COEFFICIENTS

Posted By: Luca Evans     Category: C Programming     Views: 4020

EVALUATION OF BINOMIAL COEFFICIENTS.

Code for EVALUATION OF BINOMIAL COEFFICIENTS in C Programming

#define     MAX     10                                          
   main()                                                          
   {                                                               
       int  m, x, binom;                                           
       printf(" m x");                                             
       for (m = 0; m <= 10 ; ++m)                                  
           printf("%4d", m);                                       
       printf("\n-------------------------------------------\n");                                  
       m = 0;                                                      
       do                                                          
       {                                                           
           printf("%2d  ", m);                                       
           x = 0; binom = 1;                                              
           while (x <= m)                                          
           {                                                       
               if(m == 0 || x == 0)                                
                  printf("%4d", binom);                            
               else                                                
                  {                                                
                     binom = binom * (m - x + 1)/x;                
                     printf("%4d", binom);                         
                  }
               x = x + 1;                                          
           }                                                       
           printf("\n");                                           
           m = m + 1;                                              
       }                                                           
       while (m <= MAX);                                           
       printf("---------------------------------------------\n");                                    
   }
                                                               
Output     m x   0   1   2   3   4   5   6   7   8   9  10            
       ---------------------------------------------------            


    0     1                                                    
    1     1   1                                                
    2     1   2   1                                            
    3     1   3   3   1                                        
    4     1   4   6   4   1                                    
    5     1   5  10  10   5   1                                
    6     1   6  15  20  15   6   1                            
    7     1   7  21  35  35  21   7   1                        
    8     1   8  28  56  70  56  28   8   1                    
    9     1   9  36  84 126 126  84  36   9   1                
   10     1  10  45 120 210 252 210 120  45  10   1  
---------------------------------------------------                                                     
  
Share: 


Didn't find what you were looking for? Find more on EVALUATION OF BINOMIAL COEFFICIENTS Or get search suggestion and latest updates.

Luca Evans
Luca Evans author of EVALUATION OF BINOMIAL COEFFICIENTS is from London, United Kingdom.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!