# C Program to compute the fibonacci series

Each number in fibonacci series is obtained by adding the previous two numbers. The base numbers of the series are 0 and 1 i.e., the numbers with what series starts. The third number in the series is the sum of 0 and 1 which is again 1. This program computes the series by stroring the base numbers in an array and then each number is computed by adding the previous two numbers.

# Source Code :

#include<stdio.h> int main() { int fib[15]; int i; fib[0] = 0; // Step 1 fib[1] = 1; // Step 1 for(i = 2; i < 15; i++) fib[i] = fib[i-1] + fib[i-2]; // Step 2 for(i = 0; i < 15; i++) // Step 3 printf("%d\n", fib[i]); return 0; }

# OUTPUT:

0 1 1 2 3 5 8 13 21 34 55 89 144 233 377

# Explanation:

Step 1: The base numbers of the series are stored in fib[0] and fib[1] respectively.

Step 2: From the third number onwards, series is computed by adding the previous two numbers.

Step 3: Now the series is in array which was printed to output screen using for loop.

# More Insights:

More Content : Explore More