
- C++ Basics
- C++ Home
- C++ Overview
- C++ Environment Setup
- C++ Basic Syntax
- C++ Comments
- C++ Data Types
- C++ Variable Types
- C++ Variable Scope
- C++ Constants/Literals
- C++ Modifier Types
- C++ Storage Classes
- C++ Operators
- C++ Loop Types
- C++ Decision Making
- C++ Functions
- C++ Numbers
- C++ Arrays
- C++ Strings
- C++ Pointers
- C++ References
- C++ Date & Time
- C++ Basic Input/Output
- C++ Data Structures
- C++ Object Oriented
- C++ Classes & Objects
- C++ Inheritance
- C++ Overloading
- C++ Polymorphism
- C++ Abstraction
- C++ Encapsulation
- C++ Interfaces
C++ Program to Compute Combinations using Recurrence Relation for nCr
This is a C++ program to compute Combinations using Recurrence Relation for nCr.
Algorithms
Begin function CalCombination(): Arguments: n, r. Body of the function: Calculate combination by using the formula: n! / (r! * (n-r)!. End
Example
#include<iostream> using namespace std; float CalCombination(float n, float r) { int i; if(r > 0) return (n/r)*CalCombination(n-1,r-1); else return 1; } int main() { float n, r; int res; cout<<"Enter the value of n: "; cin>>n; cout<<"Enter the value of r: "; cin>>r; res = CalCombination(n,r); cout<<"\nThe number of possible combinations are: nCr = "<<res; }
Output
Enter the value of n: 7 Enter the value of r: 6 The number of possible combinations are: nCr = 2
- Related Articles
- Haskell Program To Perform nCr (r-combinations)
- C++ Program to Compute Combinations using Factorials
- C program to find nth term of given recurrence relation
- How To Perform nCr (r-combinations) in Golang?
- Find nth term of a given recurrence relation in Python
- Find nth term of a given recurrence relation in C++
- Practice Set for Recurrence Relations
- Java Program to Perform nCr (rcombinations)
- Swift Program To Perform nCr (rcombinations)
- Program to calculate value of nCr in C++
- C Program find nCr and nPr.
- Program to find nCr values for r in range 0 to n, in an efficient way in Python
- C++ Program to Compute Discrete Fourier Transform Using Naive Approach
- How to compute Average for the Set of Values using C#?
- C++ Program to Compute the Area of a Triangle Using Determinants

Advertisements