Tuesday, 27 November 2012

NCR

using System;
using System.Collections.Generic;
using System.Text;

namespace ncr
{
class ncr
{
static void Main(string[] args)
{
int n1 = 1,nr1=1, r1 = 1, n,i, r, ans, nr;
Console.WriteLine("\tNCR");
Console.WriteLine("\t****");
Console.WriteLine("Enter The n Value");
n = int.Parse(Console.ReadLine());
Console.WriteLine("Enter The r Value");
r = int.Parse(Console.ReadLine());
if (n > r)
{
nr = n - r;
for (i = 1; i <= n; i++)
{
n1 = n1 * i;
}
for (i = 1; i <= r; i++)
{
r1 = r1 * i;
}
for (i = 1; i <= nr; i++)
{
nr1 = nr1 * i;
}
ans = n1 / (nr1 * r1);
Console.WriteLine("The NcR Value={0}", ans);
}
else
{
Console.WriteLine("The N Value Must Greater than R Value");
}
}
}
}

No comments:

Post a Comment