Search C Program | nimishsoft@gmail.com

Fibonacci Series using while loop

/* Fibonacci Series using while loop */
// 0 1 1 2 3 5 8 13...
#include<stdio.h>
int main()
{
    int n,i,a,b,c;
    printf("Enter a number: ");
    scanf("%d",&n);
    i=1;
    a=0;
    b=1;
    while(i<=n)
    {
        printf("%d ",a);
        c = a + b;
        a = b;
        b = c;
        i++;
    }
    return 0;
}

Related Post:
Fibonacci series using for loop
http://cbasicprogram.blogspot.in/2012/03/fibonacci-series-using-for-loop.html

10 comments:

  1. int main()
    {
    int i=0,j=1;
    int c,n,count=0,d;
    cout<<"enter num";
    cin>>n;
    c=i+j;
    cout<<i<<j;
    while(count<n-2)
    { d=j+c;
    cout<<d;
    j=c;
    c=d;
    count++;
    }
    return 0;
    }

    ReplyDelete
    Replies
    1. great ... . .its working thnx fr the infrmtn

      Delete
    2. Attention everyone, the file provided above is not working. I have been looking for the working file and finally found it.



      ✔️Click Here To Download http://gestyy.com/e0GAyS
      ✔️Click Here To Download

      ✔️Click Here To Download http://exe.io/XONVsO6l

      ✔️Click Here To Download


      ✔️Click Here To Download
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .

      .

      .
      .

      .

      .
      .
      .
      .

      Mn.
      ..

      .
      .
      .
      ..
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      ..
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .xzxz
      .sdcccxxx

      Delete
  2. Replies
    1. To start the loop in the series form till the Nth given number

      Delete
  3. if i will take n=1 only then,
    will it show result 0? according to me 0 and 1 both will print on the monitor

    ReplyDelete
  4. why we take while(ao,
    please suggest me!!

    ReplyDelete
  5. Fibonacci Series in C
    Lovely post, thanks for sharing good article with us.

    ReplyDelete