THIS ASSIGNMENT MUST BE DONE IN C, NOT C++! This assignment focuses on creating and manipulating selection control structur

Question

THIS ASSIGNMENT MUST BE DONE IN C, NOT C++!


This assignment focuses on creating and manipulating selection control structures.


The term combination in elementary algebra refers to one of the different ways a certain number of items can be selected from a list of items. For example, the combinations of four items a,b,c,d taken three at a time are abc, abd, acd, and bcd. In other words, there are a total of four different combinations of four things "taken three at a time". In general, the number of combinations of n things taken k at a time is combinations = n! / ((n-k)!*k!), where the "!" is the symbol for factorial. The value of n! is n*(n-1)*(n-2)*...*1. For example, 4! = 4*3*2*1 = 24. Languages such as C typically provide a function to compute factorials, but in this assignment you need to do the computation in your own code (this requires looping). In other words, don't use the library functions to compute combinations or factorials - do it in your program.


The assignment is to create a program to display the number of combinations where n and k are entered by the user. Do not use the built-in C function to compute either combinations or factorials - do the arithmetic in your program!

Input


Integer value for n, the number of items in the list

Integer value for k, the number of items to choose from the list


Reject any input greater than 10 or less than 1 by displaying an error message and then asking the user to re-enter the input. Do this as many times that they enter incorrect input. This applies both to n and k.


Additionally for k, there is an extra condition that k <= n="" p="">


Output


The number of combinations of n things taken k at a time as an integer.


Assume that all of the internal calculations can be done using integers, i.e. don't worry about integer overflow.


Output should be formatted as shown in the sample.



Sample Output

Enter the number of items in the list (n):-1

?Invalid input: Number must be between 1 and 10

Enter the number of items in the list (n):11

?Invalid input: Number must be between 1 and 10

Enter the number of items in the list (n):4

Enter the number of items to choose (k):0

?Invalid input: Number must be between 1 and 4

Enter the number of items to choose (k):99

?Invalid input: Number must be between 1 and 4

Enter the number of items to choose (k):3

Number of combinations: 4

Details
Purchase An Answer Below

Have a similar question?