Fibonacci - Turbo C++ programming


The Fibonacci Sequence is the series of numbers:
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, ...
The next number is found by adding up the two numbers before it.

Screen Shot:


//Fibonacci made by : Alfred Drio
//Visit us: www.web-offers.tk 
#include<stdio.h>
#include<conio.h>
#include<dos.h>
main()
{
 int a,b,c,i;
 a = 1;
 b = 1;
 c = 1;
 clrscr();
 for(i = 1; i <=10; i++)
 {
  printf("%d ",c);
  if(i >=2)
   {
     c = a + b;
     b = a;
     a = c;
   }
 }
 getche();
 return 0;
}

No comments:

Post a Comment