Problem Solving with C++ (9th Edition)
Problem Solving with C++ (9th Edition)
9th Edition
ISBN: 9780133591743
Author: Walter Savitch
Publisher: PEARSON
Question
Book Icon
Chapter 14, Problem 3PP
Program Plan Intro

Compute the value of “C(n, r)” using iterative version

Program plan:

  • Include required header file.
  • Declare the function for compute factorial of “n”.
  • Define main function.
    • Declare variable for “n” and “r”.
    • Declare a “double” variable for “Cvalue”.
    • Create prompt statement for “n” and “r”.
    • Read the value of “n” and “r” from user.
    • Compute the value of “Cvalue” using the given formula by calling the function “computeFactorial”.
    • Display the result for number of ways for selecting from given “n”.
  • Define “computeFactorial” function with argument “n”.
    • Initializes the value of factorial result to “1”.
    • Using “for” loop, compute the value of factorial.
    • Finally result the factorial result.

Blurred answer
Students have asked these similar questions
Write a recursive function that returns true if the digits of a positive integer are in increasing order; otherwise, the function returns false. Also, write a program to test your function.
Write a recursive function, sumDigits, that takes an integer as a parameter and returns the sum of the digits of the integer. Also, write a program to test your function.
Write a recursive function that takes a positive integer and returns the factorial of that integer. Attention, the function must be recursive, and its name must be "fatorial".
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning