/*Fibonacci Series up
to user Given number Using C++
Series Limit is Defined by User
*/
#include<iostream.h>
#include<conio.h>
void main()
{
int n,i,fst=0,sec=1,num;
cout<<" Enter number for Fibonacci Series “;
cin>>num;
cout<<" Fibonacci Series 0 to” <<num <<”number”;
for(i=0;i<= num;i++)
{
if(i<=1)
{
n=i;
}
else
{
n= fst+sec;
fst=sec;
sec=n;
}
Cout<<”\t”<<n;
}
getch();
}
Series Limit is Defined by User
*/
#include<iostream.h>
#include<conio.h>
void main()
{
int n,i,fst=0,sec=1,num;
cout<<" Enter number for Fibonacci Series “;
cin>>num;
cout<<" Fibonacci Series 0 to” <<num <<”number”;
for(i=0;i<= num;i++)
{
if(i<=1)
{
n=i;
}
else
{
n= fst+sec;
fst=sec;
sec=n;
}
Cout<<”\t”<<n;
}
getch();
}
No comments:
Post a Comment