//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...
-
//Program to print multiplication table up to n numbers import java.util.*; class mtable { public static void main(String args[])...
-
//Program to find largest and smallest in a list of numbers import java.util.*; class largesmall { public static void main(Str...
-
//Program to find LCM of two(2) numbers. import java.util.Scanner; class lcm { public static void main(String args[]) { ...
No comments:
Post a Comment