#include<iostream.h>
#include<conio.h>
void main()
{
int
x=0,a=0,b=1,n;
clrscr();
cout<<"Enter
how many no to print in fib series\n";
cin>>n;
clrscr();
cout<<"Fibonacci
Series is: \n\n";
while(n>0)
{
cout<<a<<"\n";
x=a+b;
a=b;
b=x;
n--;
}
getch();
}
----------------------------------------------------------------------------------------------------------------------------------------
#include<iostream.h>
#include<conio.h>
void main()
{
int
a=0,b=1,n;
clrscr();
cout<<"Enter
how many no to print in fib series\n";
cin>>n;
clrscr();
cout<<"Fibonacci
Series is: \n\n";
while(n>0)
{
cout<<a<<"\n";
b=a+b;
a=b-a;
n--;
}
getch();
}
----------------------------------------------------------------------------------------------------------------------------------------
#include<iostream.h>
#include<conio.h>
void main()
{
int
x=0,a=0,b=1,n;
clrscr();
cout<<"Enter
how many no to print in fib series\n";
cin>>n;
clrscr();
cout<<"Fibonacci
Series is: \n\n";
while(n>0)
{
cout<<x<<"\n";
a=b;
b=x;
x=a+b;
n--;
}
getch();
}
----------------------------------------------------------------------------------------------------------------------------------------
#include<iostream.h>
#include<conio.h>
void main()
{
int
x=0,a=0,b=1,n;
clrscr();
cout<<"Enter
how many no to print in fib series\n";
cin>>n;
clrscr();
cout<<"Fibonacci
Series is: \n\n";
while(n>0)
{
x=a+b;
cout<<a<<"\n";
a=b;
b=x;
n--;
}
getch();
}
----------------------------------------------------------------------------------------------------------------------------------------
#include<iostream.h>
#include<conio.h>
void main()
{
int
x=0,a=0,b=1,n;
clrscr();
cout<<"Enter
how many no to print in fib series\n";
cin>>n;
clrscr();
cout<<"Fibonacci
Series is: \n\n";
while(n>0)
{
cout<<a<<"\n";
a=b;
b=a+x;
x=a;
n--;
}
getch();
}
----------------------------------------------------------------------------------------------------------------------------------------
#include<iostream.h>
#include<conio.h>
void main()
{
int
x=0,a=0,b=1,n;
clrscr();
cout<<"Enter
how many no to print in fib series\n";
cin>>n;
clrscr();
cout<<"Fibonacci
Series is: \n\n";
while(n>0)
{
cout<<x<<"\n";
a=b;
b=a+x;
x=a;
n--;
}
getch();
}
----------------------------------------------------------------------------------------------------------------------------------------
#include<iostream.h>
#include<conio.h>
void main()
{
int
x=1,a=0,b=1,n;
clrscr();
cout<<"Enter
how many no to print in fib series\n";
cin>>n;
n=n-2;
clrscr();
cout<<"Fibonacci
Series is: \n\n";
cout<<0<<"\n";
cout<<1<<"\n";
while(n>0)
{
a=b;
b=a+x;
x=a;
cout<<a<<"\n";
n--;
}
getch();
}
----------------------------------------------------------------------------------------------------------------------------------------
#include<iostream.h>
#include<conio.h>
void main()
{
int
x=0,a=0,b=1,n;
clrscr();
cout<<"Enter
how many no to print in fib series\n";
cin>>n;
n=n-2;
clrscr();
cout<<"Fibonacci
Series is: \n\n";
cout<<0<<"\n";
cout<<1<<"\n";
while(n>0)
{
x=a+b;
cout<<x<<"\n";
a=b;
b=x;
n--;
}
getch();
}
----------------------------------------------------------------------------------------------------------------------------------------
Output:
Enter how many no to print in fib series
10
Fibonacci Series is:
0
1
1
2
3
5
8
13
21
34