//Program to generate nth term in Fibonacci series
#include<iostream>
using namespace std;
int main()
{
int f1=1,f2=1,f3=0,n,i;
cout<<"enter the term you want to find : ";
cin>>n;
if(n==1)
cout<<f1;
else if(n==2)
cout<<f2;
else if(n>=3)
{
for(i=3;i<=n;i++)
{
f3=f1+f2;
f1=f2;
f2=f3;
}
cout<<f3<<"\n";
}
return 0;
}
A similar program to this:
C++ Program to generate Fibonacci series
14 September 2018
C++ Program to generate nth term in Fibonacci series
Subscribe to:
Post Comments (Atom)
To convert from Upper case to lowercase(A to a)
//converting from Upper to lower(A to a) import java.util.*; class case { public static void main(String args[]) { System.out.pr...
-
Perfect number : is a positive integers which is equal to the sum of its proper positive divisors, that is, the sum of its positive...
-
//Program to calculate area of circle using SWITCH statement import java.util.*; class switch1 { public static void main(String a...
-
//C++ program to calculate x^n using recursion #include<iostream> using namespace std; int xn(int,int); int main() { ...
No comments:
Post a Comment