#include <stdio.h>
int main() {
int n, r;
printf("Enter the value of n and r: \n");
scanf("%d%d", &n,&r);
if (n < 0 || r < 0 || n < r)
{
printf("Invalid input\n");
return 1;
}
int nfact = 1,rfact = 1,nmrfact = 1;
for (int i = 1; i <= n; i++)
{
nfact *= i;
}
for (int i = 1; i <= r; i++)
{
rfact *= i;
}
for (int i = 1; i <= (n - r); i++)
{
nmrfact *= i;
}
int permutation = nfact/ nmrfact;
int combination = nfact / (rfact * nmrfact);
printf("Permutation (nPr) = %d\n", permutation);
printf("Combination (nCr) = %d\n", combination);
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: