C++

Assignment 02



then write a program, and save it in lab02.cpp, that asks how many
numbers it should generate in the Fibonacci series.

Remember that the first two numbers are

    0 and 1

so you already have two numbers in the series when you start.

Please write a function named Fibonacci that takes an int indicating
the length of the series. The function prototype could look like

    void Fibonacci( int length );

Use a local array of size 20 to store the sequence of numbers and
then print the sequence in reverse order (largest number first);
display 6 numbers per line and use 5 positions for each number;
if the user asked for 20 numbers, your program should display

 4181 2584 1597  987  610  377
  233  144   89   55   34   21
   13    8    5    3    2    1
    1    0

Your program should make sure that length the series (i.e., the
int being passed to the Fibonacci function) is >= 2 and <= 20;
otherwise your program should display a message that length is out of
bounds and terminate the execution.

This assignment is due on the BlackBoard by midnight one week from
the day it was assigned. Submit only the lab02.cpp file.
No late assignments.


Please
    - use braces around any block
    - use blocks as we did in our class examples
    - indent your code as we have used indentations in our examples
    - comment your code; do not over comment your code


Penalties:
    o -2 for each missing block

    o -2 for each missing indentation

    o no credit if your cpp file does not compile or does not run

    o some partial credit if your program crashes with different
      input values depending on the problem


Extra credit:
    - one extra point if your program correctly allocates and deallocates
      a dynamic array for length elements instead of using a fixed size
      array of size 20 to hold the numbers in the Fibonacci series.

end of lab 02.

    • 11 years ago
    Complete A++ Solution
    NOT RATED

    Purchase the answer to view it

    blurred-text
    • attachment
      fibonacciseries.zip