Program Console Vignaankosh.com
Execution Panel
Console is empty.
Geometric Progression (nth term) - 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>
// GP: a, ar, ar?, ar?, ...
// nth term = a * r^(n-1)
int gpTerm(int a, int r, int n) {
if(n == 1) {
return a;
}
int previousTerm = gpTerm(a, r, n - 1);
int currentTerm = r * previousTerm;
return currentTerm;
}
int main() {
int firstTerm = 3;
int ratio = 2;
int position = 5;
int term = gpTerm(firstTerm, ratio, position);
printf("GP: a=%d, r=%d\n", firstTerm, ratio);
printf("%dth term = %d\n", position, term);
return 0;
}