#include
int factor (int num)
{
if (num>1)
{
return (num * factor(num-1));
}
else{}
return (1);
}
int main(void)
{
int firstnum,secnum,permdin,permfact,sub1;
printf("Enter First Number:");
scanf("%d",&firstnum);
printf("%d = %d \n\n\n",firstnum,factor(firstnum));
printf("Enter Second Number:");
scanf("%d",&secnum);
printf("%d = %d \n\n\n",secnum,factor(secnum));
if(firstnum>secnum)
{
sub1=firstnum-secnum;
permdin=factor(sub1);
permfact=(factor(firstnum)/permdin);
printf("Permutation = %d\n\n\n",permfact);
printf( "Combination : %d\n\n\n",factor(firstnum) / (factor(secnum)* factor(firstnum-secnum)));
printf("\n\n\n");
}
else
{
printf("Invalid:\n\n\n");
}
return 0;
}
No comments:
Post a Comment