Program Console Vignaankosh.com
Execution Panel
Console is empty.
R26 Trace recursion (print call stack flow) 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>
int traceFactorial(int n, int depth) {
for(int i = 0; i < depth; i++) printf(" ");
printf("fact(%d) called\n", n);
if(n <= 1) {
for(int i = 0; i < depth; i++) printf(" ");
printf("fact(%d) returns 1\n", n);
return 1;
}
int smallerResult = traceFactorial(n-1, depth + 1);
int result = n * smallerResult;
for(int i = 0; i < depth; i++) printf(" ");
printf("fact(%d) returns %d\n", n, result);
return result;
}
int main() {
traceFactorial(4, 0);
return 0;
}