ASSIGNMENT# 01 Advance Algorithm
ASSIGNMENT# 01 Advance Algorithm
while(1){
printf("\n1. Permutation\n2. Combination\n3. Factorial\n");
printf("Choose option: ");
scanf("%d",&choice);
switch(choice){ //start of switch statement
case 1:
printf("Enter value of n,r: ");
scanf("%d%d",&n,&r);
//calculation of combination with function call
printf("Permutation P(%d,%d) = %d",n,r,permutation(n,r));
break;
case 2:
printf("Enter value of n,r: ");
scanf("%d%d",&n,&r);
printf("Combination C(%d,%d) = %d",n,r,combination(n,r));
break;
case 3:
printf("Enter value of n: ");
scanf("%d",&n);
printf("The factorial %d! = %d",n,factorial(n));
break;
default: //if user enter other than 1 or 2
printf("Invalid choice! Enter either 1 or 2");
} //end of switch statement
printf("\nWant another calculation?(y/n):");
if(getche()=='n')
break;
}
return 0;
}//end of main