The expression C(n,r) denotes the number of r -element subsets of an n -element
ID: 3612817 • Letter: T
Question
The expression C(n,r) denotes the number ofr-element subsets of an n-element set. Thisis a combinatorial function pronounced as “n chooser”. For example, given a set of 4 colors
{ red, blue, green, yellow }, how many distinct sets of 2 colorscan we make? (Note: the sets { red, blue } and { blue,red } are not-distinct.) C(4,2)=6 , hencethere are six distinct subsets of 2 elements – { red, blue },{ red, green }, { red, yellow }, { blue, green }, { blue, yellow },and { green, yellow }. The value of C(n,r) is given bythe formula
Write a program in C that computes C(n,r) using the followingcomponent functions
i. main(): prompts the user for two numbersstoring them in variables n andr respectively; and then prints theresult after C(n,r) is computed.
ii. check(): compares r and n. If r >n or if r orn are negative, check()invokes the function err_msg() which prints anerror message. The program will then terminate.
iii. comb(): computesC(n,r) .
iv. fact(): computes afactorial.