- Hello World c
- C Program to Add Two Numbers
- Area of Triangle C
- Odd or Even C
- Write a C program to find the sum of digitis of a given number
- Write a C program to find the maximum of three numbers
- Write a C program to swap two number using third variable
- Write a C program to swap to numbers without using third variable
- Write a C program to calculate the area of circle
- Write a C program to calculate the Binomial Coefficient (nCr)
- Write a C program to calculate the permutations (nPr)
- Write a C program to reverse the number
- Write a c program to check the given number is palindrome or not
- Write a c program to check the given number prime or not
- Write a c program to check the given number is armstrong or not
- Write a C program to generate all Armstrong number till n
- Write a program to check given number perfect or not
- Write a C program to check alphabet is vowel or consonant
- Write C program to calculates the factorial of a given number
- Write a C program generate and prints the Fibonacci series up to a user-defined limit
- Write a C program to calculate the nth number in the Fibonacci series using recursion
- Write a C program to find the maximum element in the array
- Write a C program to find the minimum element in the array
- Write a C program to search the element using linear search technique
- Write a C program to Insert element in array

**nCr**, is a mathematical notation representing the number of ways to choose r items from a set of n items, where order does not matter and repetitions are not allowed. It is also known as the **binomial coeffiecient** and is represented by the formula: **nCr = n! / (r! * (n - r)!)**.

where n! represents the factorial of n, or the product of all positive integers up to n. The **binomial coefficient nCr** is often used in **combinations**, probability theory, and other areas of mathematics and statstics.

```
// write a c program to calculate nCr.
#include<stdio.h>
int factorial(int n){
int fact = 1;
for(int i = 1; i <= n; i++){
fact *= i;
}
return fact;
}
int nCr(int n, int r){
int nCr = factorial(n) / (factorial(r) * factorial(n - r));
return nCr;
}
int main(){
int n, r;
printf("Enter the value of n : ");
scanf("%d", &n);
printf("Enter the value of r : ");
scanf("%d", &r);
int result = nCr(n, r);
printf("nCr = %d", result);
return 0;
}
```

`#include<stdio.h>`

This line of code includes the **standard input/output** library, which provides the function for input and output operations.

```
// function to calculate factorial.
int factorial(int n){
int fact = 1;
for(int i = 1; i <= n; i++){
fact *= i;
}
return fact;
}
```

This function calculates the **factorial** of a given integer n, using a for loop that iterates from 1 o n, multiplying the variable **"fact"** by i at each iteration.

```
// function to calculate nCr.
int nCr(int n, int r){
int nCr = factorial(n) / (factorial(r) * factorial(n - r));
return nCr;
}
```

This function calculates the binomial coeffcient nCr, which is the number of ways to choose r items from a set of n items. It uses the factorial function to calculate the **numerator** and **denominator** of the **binomial coefficient** formula.

```
// main function (Entry point of program)
int main(){
int n, r;
printf("Enter the value of n : ");
scanf("%d", &n);
printf("Enter the value of r : ");
scanf("%d", &r);
int result = nCr(n, r);
printf("nCr = %d", result);
return 0;
}
```

This is the main function that calls the **nCr function** and reads input values for n and r using the **scanf() function**. It then computes the binomial coefficient using the nCr function and prints the result to the console using **printf() function**. The main function returns 0 to indicates successful execution of the program.

- Include the standard input/output library.
- Define a function to calculate the factorial of a given integer n.
- Define a function to calculate the
**binomial coeffiecient nCr**using the**factorial function**. - In the main function, read input values for n and r using the scanf() function.
- Compute the binomial coefficient using the nCr funciton.
- Print the result to the console using printf.
- End the program.

```
// Pseudocode to calculate nCr.
1. INCLUDE stdio.h
2. FUNCTION factorial(n)
1. SET fact = 1
2. FOR i = 1 to n
1. SET fact = fact * i
3. RETURN fact
3. FUNCTION nCr(n, r)
1. SET nCr = factorial(n) / (factorial(r) * factorial(n - r))
2. RETURN nCr
4. FUNCTION main()
1. DECLARE n, r, result AS INTEGER
2. PRINT "Enter the value of n : "
3. READ n FROM USER
4. PRINT "Enter the value of r : "
5. READ r FROM USER
6. SET result = nCr(n, r)
7. PRINT "nCr = ", result
8. RETURN 0
```

ðŸ–¤ 0

Buy me coffee â˜•

## Comments

Oops!