Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program lab 2 Problem 2 . c to calculate the permutation and combination for given n and r . The values of

Write a program "lab2Problem2.c" to calculate the permutation and combination for
given n and r. The values of n and r should be passed to the program as a command-
line argument. The permutation and combination are defined for given n and r as:
P(n,r)=n!(n-r)!,C(n,r)=P(n,r)r!
Output Format:
P(5,3)=60
C(5,3)=10
Requirement:
The program should take 2 command-line arguments. First argument
should be the value of n and the second argument should be the value of r.
First create a factorial function. Then, you can use the factorial function in
the functions to compute permutation and combination.
The result should be printed in the main function.
Sample Run:
(base) jovyanejupyter-asainju: /3240/1ab2$ gcc 1ab2Problem2,c -o 1ab2Problem2
ab2$./1ab2Problem253
P(5,3)=60
c(5,3)=10
ab2$./1ab2Problem2205
P(20,5)=1860480
c(20,5)=15504
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions