Fibonacci series in c language

              Fibonacci series in c language

Fibonacci series is series of number in which any number is sum of it's preceding two number.This blog will introduce you to the concept of how to write program to print Fibonacci series in c language.


             Example of Fibonacci series:  0  1  1  2  3  5  8  13  ...................

https://programminghub1999.blogspot.com/2018/12/fibonacci-series-in-c-language.html



                     Following method has used in program

  1. First two term of Fibonacci series is constant.
  2. Take two constant term .
  3. Ask user up to what limit he want to print Fibonacci series.
  4. Run the iteration till the last term of Fibonacci term.
  5. Then apply the condition to print Fibonacci series inside iteration.
  6. Print the Fibonacci series.

                       

             Printing Fibonacci series in c language.

 The following code has run in turbo compiler.I personally use turbo editor for 
  writing my c language program.


#include<stdio.h>
#include<conio.h>
void main()
{
    clrscr();
    int fib1=0,fib2=1,fib3,count=0,limit;
    printf("Enter limit\n");
    scanf("%d",&limit);
    printf("%d",fib1);
    printf("%d",fib2);
    count=2;
    while(count<limit)
    {
          fib3=fib1+fib2;
          printf("%d",fib3);
          fib1=fib2;
          fib2=fib3;
          count++;
    }
     getch();
}

    



                                       
Fibonacci series in c language Fibonacci  series in c language Reviewed by Deepak kumar soni on December 29, 2018 Rating: 5

No comments:

Powered by Blogger.