Fibonnaic Sequence

 

*.Fibonnaic sequence :- The Fibonnaic Sequence is a series of numbers in which each number is the sum of two preceding numbers.


#.Code :- 


#include<iostream>
using namespace std;
void adtn_fun(int x,int y,int z){
    for(int i=0;i<z;i++){
        int sum=x+y;
        cout<<(i+1)<<". : "<<x<<" + "<<y<< " = "<<sum<<endl;
        int temp=x;
        x=y;
        y=sum;
        sum=temp;
    }
}
int main(){
    int n1,n2;
    cout<<"enter 1st num : ";
    cin>>n1;
    cout<<"enter 2nd num : ";
    cin>>n2;
    int loop;
    cout<<"enter how many times you want to perform function : ";
    cin>>loop;
    adtn_fun(n1,n2,loop);
    return 0 ;
}



#.Output :- 




Comments

Popular posts from this blog

To do addition of all the Elements of Array in C++

A program to Search element in array , and if repeated so at which location it is present and how many time the number is repeated

Take n no. Of elements and arrange them in Ascending & Descending Order