/*
To Print n Fibonacci Numbers (Fibonacci Series)
1 1 2 3 5 8 13 21 ......n .
Fibonacci Series is also believed to start from 0 in many colleges depending upon the acceptance .
To modify this prog to print 0 1 1 2 3 5 8 21 ......n.
Change the value of x=0 .
*/
#include<iostream.h>
#include<conio.h>
Void main()
{
int x,y,z;
clrscr();
cout<<"Enter the no upto which series required";
cin>>n;
x=1;
y=1;
cout<<"THE FOLLOWING ARE THE FIRST "<<n<<" FIBONACCI NUMBERS";
cout<<x<<" "<<y<<" ";
for(int i=1;i<=(n-2);i++)
{
z=x+y;
cout<<z<<"\t";
x=y;
y=z;
}
getch();
}
To Print n Fibonacci Numbers (Fibonacci Series)
1 1 2 3 5 8 13 21 ......n .
Fibonacci Series is also believed to start from 0 in many colleges depending upon the acceptance .
To modify this prog to print 0 1 1 2 3 5 8 21 ......n.
Change the value of x=0 .
*/
#include<iostream.h>
#include<conio.h>
Void main()
{
int x,y,z;
clrscr();
cout<<"Enter the no upto which series required";
cin>>n;
x=1;
y=1;
cout<<"THE FOLLOWING ARE THE FIRST "<<n<<" FIBONACCI NUMBERS";
cout<<x<<" "<<y<<" ";
for(int i=1;i<=(n-2);i++)
{
z=x+y;
cout<<z<<"\t";
x=y;
y=z;
}
getch();
}
No comments:
Post a Comment