Write a C++ program to compute the nCr In permutations and combinations, the term nCr refers to n combinations taken r at a time. n! nCr = r! (n – r)!
Write a C++ program to compute the nCr In permutations and combinations, the term nCr refers to n combinations taken r at a time. n! nCr = r! (n – r)!
C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter15: Recursion
Section: Chapter Questions
Problem 6PE
Related questions
Question
![Write a C++ program to compute the nCr
In permutations and combinations, the term nCr refers to n combinations taken r at a time.
n!
nCr =
r! (n – r)!
.Write a recursive function to find the factorial of a number.
.Use the defined function to compute the term nCr for the following scenario:
•The values of "n" and "r" are stored in two parallel arrays of any user defined size.
• You have to Read the arrays n and r at run time. Compute nCr for each corresponding terms in the array "n" and "r",
store it in another separate array and display the output array properly formatted.
• Also your program should print the current date and time using library functions.
Sample input:
Index
Array 'n'
22
13
4.
Array T
3
Computed nCr
1540
1287
1
2
2.
6.
3
16
560
100947
18564
23
18
15
18
22
6.
6.
7
8
9.
4.
1364
816
26334
5.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F154b644b-8bbe-45fc-a8ab-b64376494ffa%2Fa271eed0-045d-418c-bb34-b4f70a7b6978%2Fe0inmfq_processed.jpeg&w=3840&q=75)
Transcribed Image Text:Write a C++ program to compute the nCr
In permutations and combinations, the term nCr refers to n combinations taken r at a time.
n!
nCr =
r! (n – r)!
.Write a recursive function to find the factorial of a number.
.Use the defined function to compute the term nCr for the following scenario:
•The values of "n" and "r" are stored in two parallel arrays of any user defined size.
• You have to Read the arrays n and r at run time. Compute nCr for each corresponding terms in the array "n" and "r",
store it in another separate array and display the output array properly formatted.
• Also your program should print the current date and time using library functions.
Sample input:
Index
Array 'n'
22
13
4.
Array T
3
Computed nCr
1540
1287
1
2
2.
6.
3
16
560
100947
18564
23
18
15
18
22
6.
6.
7
8
9.
4.
1364
816
26334
5.
Expert Solution
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps with 1 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
![C++ Programming: From Problem Analysis to Program…](https://www.bartleby.com/isbn_cover_images/9781337102087/9781337102087_smallCoverImage.gif)
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
![C++ for Engineers and Scientists](https://www.bartleby.com/isbn_cover_images/9781133187844/9781133187844_smallCoverImage.gif)
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
![C++ Programming: From Problem Analysis to Program…](https://www.bartleby.com/isbn_cover_images/9781337102087/9781337102087_smallCoverImage.gif)
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
![C++ for Engineers and Scientists](https://www.bartleby.com/isbn_cover_images/9781133187844/9781133187844_smallCoverImage.gif)
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr