Latest Posts

Thursday, February 26, 2015

C Program To Print Fibonacci Series

                                      Fibonacci Series



This is a series in which we give the first two numbers in the series and the rest of the series is obtained by addition of the newly formed number and the before number.The below program prints the Fibonacci series.The program uses while loop.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
#include<stdio.h>
#include<conio.h>
void main()
{ int a=0,b=1,c=0,n;
  clrscr();
  printf("Enter n:\n");
  scanf("%d",&n);
  printf("%d\t%d\t",a,b);
  while(c<n)
  { c=a+b;
    if(c<=n)
    printf("%d\t",c);
    a=b;
    b=c;
  }
  getch();
  }
Please Like,Share and subscribe to my posts.

Thanks For Visiting.
no image
  • Blogger Comments
  • Facebook Comments

0 comments:

Post a Comment

Top