Generate Fibonacci numbers into array. - C Data Type

C examples for Data Type:int

Description

Generate Fibonacci numbers into array.

Demo Code

#include <stdio.h>

int main(void) {
   int i;/*  w  w  w.  j  a v a2 s.  c  o  m*/
   const int numFibs = 20;

   unsigned long long int Fibonacci[numFibs];

   Fibonacci[0] = 0;   // by definition
   Fibonacci[1] = 1;   // by definition

   for (i = 2; i < numFibs; ++i)
      Fibonacci[i] = Fibonacci[i - 2] + Fibonacci[i - 1];

   for (i = 0; i < numFibs; ++i)
      printf("%llu ", Fibonacci[i]);

   printf("\n");

   return 0;
}

Result


Related Tutorials