Sunday, 1 September 2013

To generate nPr (PERMUTATION)

Posted by Unknown On 10:31 | No comments

/* Program to generate Permutation (nPr) */

/* Here we will be generating the Permutation. We are taking the the n and r as a input from the user and will generate the desire output. */

/* Program to calculate Permutation nPr */

//Header File

#include<iostream.h>
int fact(int);
int main()
{
int  a,b,n,r;
cout<<"\n Enter the value of n : ";
cin>>n;
cout<<"\n Enter the value of r : ";
cin>>r;
a=fact(n);
b=fact(n-r);
cout<<"\n Value of permutation : "<<a/b;
return 0;
}
int fact(int a)
{
int sum=1,i;
if(a==0)
return 1;
else
{
for(i=1;i<=a;i++)
{
sum=sum*i;
}
return sum;
}
}



0 comments:

Post a Comment

Blogroll

Copyright © 2013 RAJ PRAJAPATI (raj@electronicsrj.com)

Comments

About Projects

We also Provide support in making Electronics Projects at different level at Cheapest price. Contact Us for the further help.