Wednesday, August 21, 2013

Write a program in c to generate first 20 fibonacci numbers


/*------------------------------------------------------------------------------------------------
Program    : Write a program in c to generate first 20 fibonacci numbers.
Created By: JABIR DAUD PATHAN
Branch       : COMPUTER ENGINEERING
-------------------------------------------------------------------------------------------------*/

#include<stdio.h>
#include<conio.h>

void main()
 {
  int i,fno=0,sno=1,tno=0; 
  clrscr(); 
  printf("Fibonacci series==>%d%d",fno,sno);
  for(i=1;i<=20;i++)
   {
    tno=fno+sno;
    printf("\t%d",tno);
    fno=sno;
    sno=tno;
   }
  getch();
 }







/*-----------------<< OUTPUT SCREEN  >>-------------------*/


Fibonacci series==>0 1   1       2       3       5       8       13      21
34      55      89      144     233     377     610     987     1597    2584
4181    6765    10946

No comments:

Post a Comment