"KEEP LEARNING, DON'T STOP."
"KEEP LEARNING, DON'T STOP."
In this section you will learn how to make Fibonacci series program using loop in c++. Just simple mathematic operation we will perform to make the Fibonacci series program. In this program we are taking the input from user and assigning some default value to few variables.
A series of number in which each number is sum of previous two numbers. The Fibonacci series number is given below.
0, 1, 1, 2, 3, 5, 8, 13, upto n series.
0+1 =1, 1+1=2, 1+2=3, 3+5=8, 5+8=13.....
#include<iostream.h> #include<conio.h> //FIBONACCI SERIES PROGRAM void main() { int i=1, n; int f1 = 0, f2 = 1, f3; clrscr(); cout<<"ENTER A NUMBER:- "; cin>>n; cout<<f1<<f2; do { f3=f1+f2; cout<<f3; f1=f2; f2=f3; i++; } while(i<=n-1); getch(); }
ENTER A NUMBER:- 7 0 1 1 2 3 5 8 13
Advertisment