Write C++ program for Fibonacci series: 0 1 1 2 3 5 8 13

Write C++ program for Fibonacci series: 0 1 1 2 3 5 8 13




Program:

#include<iostream.h>
#include<conio.h>
void main()
{

clrscr();
int f1,f2,f3;
int n=8;
f1=0;
f2=1;
cout<<f1<<" "<<f2;
for(int i=3;i<=n;i++;)
{
f3=f1+f2;
cout<<f3<<" ";
f1=f2;
f2=f3;
}

getch();

}




No comments:

Post a Comment

We are here to listen you, Comment your valueable opinion...!!!