//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...
-
//C++ program to calculate x^n #include<iostream> using namespace std; int main() { int n,x,k; cout<<...
-
//Program to calculate LCM of two(2) numbers #include<iostream> using namespace std; int main() { int a,b,max,lcm; cout<...
-
//Program to calculate area of circle using SWITCH statement import java.util.*; class switch1 { public static void main(String a...
No comments:
Post a Comment