Generate Fibonacci series up to n terms Dry Run in C

Generate Fibonacci series up to n terms is an interactive C dry run visualizer from the For 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.

Generate Fibonacci series up to n terms Program Code

#include <stdio.h>
int main() {
    int n, a = 0, b = 1, next, i;
    printf("Enter number of terms: ");
    scanf("%d", &n);
    
    printf("Fibonacci Series: ");
    for(i = 1; i <= n; i++) {
        printf("%d ", a);
        next = a + b;
        a = b;
        b = next;
    }
    return 0;
}

View the complete For programs page.

Program Console Generate Fibonacci series up to n terms Topic: C Vignaankosh.com
Execution Panel
Step 0/0
Console is empty.