Homework assignment #3

Due Friday, November 12

A Fibonacci series is a sequence of numbers where each number is the sum of the two preceding numbers:

0, 1, 1, 2, 3, 5, 8, 13,...

Write a program to print out a Fibonacci series up to a specified number of element, which should be specified by the user. If you include the following statements in your program:

    printf ("Enter length: ");
    scanf ("%d", &length);

it will read a number from the keyboard. Notice the ampersand ("&") before length in the call to scanf; we don't know what that is yet, but it's important that it be there. Of course, you have to remember to declare the variable length as an int. Your program should then print out that number of entries. For example, if I entered the number 15, I would want to see the following:

Enter length: 15

0
1
1
2
3
5
8
13
21
34
55
89
144
233
377

Since the series relies on adding the two previous numbers in the sequence, you can't really calculate the first two entries; so you may just print out 0 and 1 to start with.

You may use the following Visual C++ workspace that I've set up for you:
Fibonacci.zip