

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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 Questions & Answers
- C++ Program to Compute Combinations using Factorials
- C program to find nth term of given recurrence relation
- 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)
- C Program find nCr and nPr.
- Program to calculate value of nCr in C++
- C program to display relation between pointer to pointer
- Program to find nCr values for r in range 0 to n, in an efficient way in Python
- 8085 Program to compute LCM
- Recurrence Equations in Data Structure
- How to compute Average for the Set of Values using C#?
- C++ Program to Compute Discrete Fourier Transform Using Naive Approach
- MySQL query to count rows with mutual relation using JOIN?
Advertisements