C Program  To Calculate Value Of ncr

In the following program we will write a C program To Calculate The Value of ncr. nCr can also be represented as C(n,r)
The formula is:
C(n,r) = n! / ( r!(n – r)! ). For 0 <= r <= n. Here ! represents factorial. For example: C(6, 2) = 6! / (2! * (6-2)!) => 720/(2 * 24) => 15

The Concept:

  1. A binomial coefficient C(n, k) can be defined as the coefficient of X^k in the expansion of (1 + X)^n.
  2. A binomial coefficient C(n, k) also gives the number of ways, disregarding order, that k objects can be chosen from among n objects; more formally, the number of k-element subsets (or k-combinations) of an n-element set.

First Example:

Best Optimized Code In Very Less Number Of Lines:

Output:

Second Example:

Output:

Top Book Suggestion

The two books on C Programming Language that I Personally Recommend. I really loved reading these books. These books are listed for quality content, easy steps, and affordable price. You can get it from Amazon and Flipkart. 

 

Check The Price On Amazon:

1. C Programming Beginner’s Guide

2. Head First C: A Brain-Friendly Guide

Check The Price On Flipkart:

1. Introduction to C Programming 

2. Head First C: A Brain-Friendly Guide

Pin It on Pinterest

Share This