The formula for the number of combinations is:
To compile a program, enter the values of M and N to find the number of combinations. It is required to define the function of the factorial and the combination, and the function of the combination number to find the function of the factorial, and in the main () function, it is responsible for the input output and the function of calling the combination number.
#include <iostream>
using namespace std;
int FAC (int);
int main ()
{
int m,n;
float C;
cout<< "Calculate C (m,n), enter values for M, n" <<endl;
cin>>m>>n;
C=FAC (m)/(FAC (n) *FAC (m-n));
cout<< "Number of combinations" <<c<<endl;
return 0;
}
int FAC (int n)
{
int i,f=1;
for (I=1; i<=n; i++)
f=i*f;
return f;
}
Should be careful to determine the size of M, n
int main ()
{
int m,n;
float C;
cout<< "Calculate C (m,n), enter values for M, n" <<endl;
cin>>m>>n;
if (m>n)
{
C=FAC (m)/(FAC (n) *FAC (m-n));
cout<< "Number of combinations" <<c<<endl;
}
Else cout<< "M should be greater than n" <<endl;
return 0;
}