Thursday, 6 October 2016

To print Fibonnaci series .

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int x=-1,y=1,i;
cout<<"Enter the no. of terms you want to print ";
cin>>i;
for (int z=0;z<=i;z++)
{
   z=x+y;
   cout<<z<<"\n";
   x=y;
   y=z;
}
getch();
}

No comments:

Post a Comment

Basic Implementation of Array as a Pointer

#include<iostream.h> #include<conio.h> void main() { clrscr();   int arr[5];   cout<<"Enter 5 nos. ";   f...