Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Q3) Using the recursive factorial function from Lecture 5, write a program that calculates n choose r Firstly, prompt the user to enter two long

image text in transcribed

Q3) Using the recursive factorial function from Lecture 5, write a program that calculates "n choose r Firstly, prompt the user to enter two long long unsigned int numbers, n and r. Do this by printing the string, "Setting combination parameters, select n and r: ". To scanf a long long unsigned int use .%11u", use the same .%11u" for printing. The factorial function must be adjusted to return a long long unsigned int as well as accept a long long unsigned int as an argument. The program must make sure that n is less than 20, and that r is less than n. If either of those conditions are not met (n greater than 20 or r greater than n), print the string "Error: n is greater than 20 or r is greater than n. ". Follow the equation: 7l The combination calculation should be inside a function with the prototye long long unsigned int combination(long long unsigned int n, long long unsigned int r); The program should print the answer. A sample output is shown below Setting combination parameters, select n and r: 10 2 45 or Setting combination parameters, select n and r: 12 6 924 or Setting combination parameters, select n and r: 24 12 Error: n is greater than 20 or r is greater than n Note: There are still NO double spaces. Name your file combinations.c

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

Question

5. Prepare for the role of interviewee

Answered: 1 week ago

Question

6. Secure job interviews and manage them with confidence

Answered: 1 week ago