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 ;
}
Comments
Post a Comment