C++
By: Max • Essay • 251 Words • March 12, 2010 • 775 Views
Page 1 of 2
C++
Fibonacci Series Using an Array
We have now used a variety the features of C. This final example will introduce the array. The program prints out a table of Fibonacci numbers. These are defined by a series in which any element is the sum of the previous two elements. This program stores the series in an array, and after calculating it, prints the numbers out as a table.
#include
main()
{ int fib[24];
int i;
fib[0] = 0;
fib[1] = 1;
for(i = 2; i < 24; i++)
fib[i] = fib[i-1] + fib[i-2];
for (i = 0; i < 24; i++)