# C program to Generate Fibonacci Seriesstarting from any two numbers

## C program to Generate the FibonacciSeries starting from any two numbers

The C program to Generate the Fibonacci Series starting from any two integer 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. ThiscC program will Generate the Fibonacci Series starting from given any two integer numbers , and add the given two numbers to generate the third number in the series, and so on. For example: If we give the starting numbers are 3 and 5 then the Fibonacci Series will be 3, 5, 8, 13, 21, . . . . The below given C program to Generate the Fibonacci Series starting with any two integer numbers. Kindly check out the program to generate the fibonacci series starting with any two integer numbers.

### Program to Fibonacci Series starting with any two integer numbers

#include<stdio.h>
int main(){
int n, firstnumber, secondnumber, sum;
printf("How many Fibonacci terms to display : ");
scanf("%d", &n);
printf("\n Give First Number : ");
scanf("%d", &firstnumber);
printf("\n Give Second Number : ");
scanf("%d", &secondnumber);
printf("\n The Fibonacci Series is . . . \n");
printf("\n %d %d ", firstnumber, secondnumber);
while (n>2){
sum = firstnumber + secondnumber;
printf("%d ", sum);
firstnumber = secondnumber;
secondnumber = sum;
n--;
}
return (0);
}

Sample Output:

How many Fibonacci terms to display : 7
Give First Number : 3
Give Second Number : 6
The Fibonacci Series is . . .
3 6 9 15 24 39 63

Related Popular Posts: