Question: --- stdio.h C program --- Problem 1. Permutation and Combination (30 points) Suppose, there are n objects and you are given the option to choose
--- stdio.h C program ---

Problem 1. Permutation and Combination (30 points) Suppose, there are n objects and you are given the option to choose r objects from them. If the order of choice matters, it is called Permutation. Otherwise, it is known as Combination. Given the values of n and r, the number of permutations, P(n, r) and combinations, C(n, r) are determined using the following formula P(n,r) - C(n,r) - where, n!-1x 2 x 3 x x (n -1) x n Write a program that takes n and r as input and calculates the corresponding number of permutations and combinations. n and r should be non-negative integers and ner. If user gives illegal inputs, your code should print a proper error message. You are required to write a user- defined function to calculate the factorial. Call the function from main function to properly calculate the permutation and combination values. For this problem, recursion is not necessary Sample Input and Output: (Your code should print the red texts on the screen. Black texts are sample user inputs) Sample Input Sample Output n: 12 r: n: r: n: r: n: r: Number of Permutation: 79833600 Number of Combination: 220 Number of Permutation: 720 Number of Combination: 1 Invalid Input Invalid Input Number of Permutation:1 Number of Combination: 1 r
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
