R25 Count number of recursive calls Dry Run in C

R25 Count number of recursive calls 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.

R25 Count number of recursive calls Program Code

#include <stdio.h>

int callCount = 0;

int fibWithCount(int n) {
    callCount++;
    if(n <= 1) {
        return n;
    }

    int first = fibWithCount(n - 1);
    int second = fibWithCount(n - 2);
    int answer = first + second;
    return answer;
}

int main() {
    int n = 5;
    callCount = 0;
    int result = fibWithCount(n);
    printf("fib(%d) = %d\n", n, result);
    printf("Number of recursive calls = %d\n", callCount);
    return 0;
}

View the complete Recursion programs page.

Program Console R25 Count number of recursive calls Topic: C Vignaankosh.com
Execution Panel
Step 0/0
Console is empty.