EssaysForStudent.com - Free Essays, Term Papers & Book Notes
Search

C++

By:   •  Essay  •  251 Words  •  March 12, 2010  •  764 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++)

Download as (for upgraded members)  txt (1.1 Kb)   pdf (49.3 Kb)   docx (10.2 Kb)  
Continue for 1 more page »