Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Print Fibonacci Series (0,1,1,2,3,5,8...)




Program which use to generate Fibonacci Series up to 0 to 15 ,, you can change the value  15 with your desire value.
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();
}

2 comments:

  1. Thankyou so much for this bro 😌💜

    ReplyDelete
  2. #include
    #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.

    ReplyDelete

Blogger Widgets

Find Us On Google, Just type - way2cplusplus -

If you have any questions on implementing or understanding this C++ Program , shoot me a comment and I'll be glad to help! :) :)