The Fibonacci Sequence is the series of numbers 0,1,1,2,3,5,8,13,21,34....
The next number is found by adding up the two numbers before it.
- The 2 is found by adding the two numbers before it (1+1)
- Similarly, the 3 is found by adding the two numbers before it (1+2),
- And the 5 is (2+3),
- and so on!
Source Code:-
#include<iostream.h>
#include<conio.h>
void main()
{ clrscr();
int a=0,b=1,c;
cout<<"Fibonacci Series Output (by: Tarun Rawat)\n\n";
cout<<"Series :- "<<a<<" "<<b;
for(int i=0;i<=15;i++)
{c=a+b;
cout<<" "<<c;
a=b;
b=c;
}
getch();
}
Thankyou so much for this bro 😌💜
ReplyDelete#include
ReplyDelete#include
int main()
{
int num1 =0,num2 =1,num3 = 0;
for (int i = 0;i<10;i++){
if (i = 0){
std::cout <<num1 <<"\n";
}else if (i ==1){
std::cout<<num2 <<"\n";
}else{
num3 = num1 + num2;
std::cout <<num3 <<"\n";
num1 = num2;
num2 = num3;
}
}
}
Need help ,please give the execution details.