Fibonacci series
#include <iostream.h> #include <conio.h> void main() { clrscr(); int i,n,first=0, second=1, next; first=0; second=1; cout<<"enter a number for fibonacci series:"; cin>>n; cout<<"fibonacci series :\n"; for(i=0;i<n;i++) { cout<<"\n"<<first; next=first+second; first=second; second=next; } getch(); }
Result:
Test Yours Self
(Visited 168 times, 1 visits today)
Written by: