This C# Program Calculates the Value of nCr. Here The Combination represented by nCr andEach r combination can be arranged in r! different ways. Then the number of r-permutations is equal to the number of r combinations times r!.

Here is source code of the C# Program to Calculate the Value of nCr. The C# program is successfully compiled and executed with Microsoft Visual Studio. The program output is also shown below.

`/*`

`* C# Program to Calculate the Value of nCr`

`*/`

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

`namespace ConsoleApplication`

`{`

`class Program`

`{`

static void Main(string[] args)

`{`

int n, r,per,fact,fact1,fact2;

Console.WriteLine("Enter the Value of 'n' and 'r' to find the Permutation :");

n = Convert.ToInt32(Console.ReadLine());

r = Convert.ToInt32(Console.ReadLine());

fact = n;

for (int i = n - 1; i >= 1; i--)

`{`

fact = fact * i;

`}`

fact2 = r;

for (int i = r - 1; i >= 1; i--)

`{`

fact2 = fact2 * i;

`}`

int number;

number = n - r;

fact1 = number;

for (int i = number - 1; i >= 1; i--)

`{`

fact1 = fact1 * i;

`}`

fact1 = fact2 * fact1;

per = fact / fact1;

Console.WriteLine("Combination : {0}",per);

Console.ReadLine();

`}`

`}`

`}`

Here is the output of the C# Program:

Enter the value of 'n' and 'r' to find the Permutation : 10 5 Combination : 252

**Sanfoundry Global Education & Learning Series – 1000 C# Programs.**

If you wish to look at all C# Programming examples, go to 1000 C# Programs.