Problem Solving with C++ plus MyProgrammingLab with Pearson eText-- Access Card Package (9th Edition)
Problem Solving with C++ plus MyProgrammingLab with Pearson eText-- Access Card Package (9th Edition)
9th Edition
ISBN: 9780133862218
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, reverseDigits, that takes an integer as a parameter and returns the number with the digits reversed. 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 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.
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