SCE

C Program to generate the Fibonacci Series starting from any two numbers

###### Posted by Samath

Last Updated:
January 02, 2017

Write a C Program to generate the Fibonacci Series starting from any two numbers. The Fibonacci series is a series of numbers in which each number of the Fibonacci series is derived by the adding of its two immediate preceding numbers.

**Code:**

#include<stdio.h> int main() { int first, second, sum, num, counter = 0; printf("How many Fibonacci terms to display: "); scanf("%d", &num); printf("\nEnter First Number : "); scanf("%d", &first); printf("\nEnter Second Number : "); scanf("%d", &second); printf("\nFibonacci Series: %d %d ", first, second); while (counter < num) { sum = first + second; printf("%d ", sum); first = second; second = sum; counter++; } return (0); }