#include
int factor (int num)
{
if (num>1)
{
return (num * factor(num-1));
}
else{}
return (1);
}
int main(void)
{
int 1num,2num,permdin,permfact;
int den,comdin,comfact,sub1,sub2;
printf("Enter First Number:");
scanf("%d",&1num);
printf("%d = %d \n\n\n\n\n\n\n",1num,factor(1num));
printf("Enter Second Number:");
scanf("%d",&2num);
printf("%d = %d \n\n",2num,factor(2num));
if(1num>2num)
{
sub1=1num-2num;
permdin=factor(sub1);
permfact=(factor(1num)/permdin);
printf("Permutation = %d\n\n",permfact);
printf( "Combination : %d",factor(1num) / (factor(2num)* factor(1num-2num)));
printf("\n\n\n");
}
else
{
printf("Invalid:\n\n");
}
return 0;
}
Factorial Permutation and Combination in C
Posted by acas arnel m. at 12:50 AM
Labels: C language codes
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment