Program Console Vignaankosh.com
Execution Panel
Console is empty.
nCr (Binomial Coefficient) - Recursion is an interactive C dry run visualizer from the Recursion programs section. Study the source code, then use the execution controls to follow each step, variable update, highlighted line, and console output.
This page provides a browser-based dry run with source-code highlighting, auto-scroll, voice narration controls, and execution output for learning the program step by step.
#include <stdio.h>
// nCr = n! / (r! * (n-r)!)
// Using Pascal's identity: nCr = (n-1)C(r-1) + (n-1)Cr
int nCr(int n, int r) {
// Base cases
if(r == 0 || r == n) {
return 1;
}
if(r > n) {
return 0;
}
// Recursive case: Pascal's rule
int left = nCr(n - 1, r - 1);
int right = nCr(n - 1, r);
int result = left + right;
return result;
}
int main() {
int n = 5, r = 2;
int result = nCr(n, r);
printf("C(%d,%d) = %d\n", n, r, result);
// Verify with Pascal's Triangle
printf("Pascal's Triangle value at row %d, col %d = %d\n", n, r, result);
return 0;
}