Sunday, 16 October 2016

HHW Q29. WAP to print Fibonacci series .

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int x=-1,y=1,z,n;
cout<<"Enter no. of terms ";
cin>>n;
for (int i=1;i<=n;i++)
{ 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...