Arduino Projects    |   Raspberry Pi  |     Electronic Circuits   |    AVR    |    PIC    |    8051    |    Electronic Projects

Display first n terms of Fibonacci series using array

Code: 
/* Display First N terms of fibonacci series
   using array Fibonaccii series are
   0 1 1 2 3 5 8 13 ..... N terms  */
#include<stdio.h>
#include<conio.h>
void main()
{
   int i,n,a[100];
   clrscr();
   printf("How many terms to be display : ");
   scanf("%d",&n);
   a[0]=0;a[1]=1;
   /* Calculaate Fibonacci series */
   for(i=2;i<n;i++)
      a[i]=a[i-1]+a[i-2];
 
printf("First %d Terms of fibonacci series \n",n);
   for(i=0;i<n;i++)
       printf("%5d",a[i]);
 
   getch();
}
You are here