Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C Project: Fibonacci Numbers Description Step 1. Your will run your program by the command (let the name of executable be Fibon): Fibon N where

C Project: Fibonacci Numbers

Description

Step 1. Your will run your program by the command (let the name of executable be Fibon):

Fibon N

where N is integer larger than 2, and your program generates sequence of N Fibonacci numbers; if N is (in any way) illegal, your program should terminate after displaying appropriate message.

As each Fibonacci number is generated, it is immediately written into the file Fibonacci. Write 4 numbers per row in the file and on the screen. You should keep the count of numbers written in the file, and print its final value on the screen.

Note: If an overflow happens, i.e. the new Fibonacci number cant be stored in the unsigned long long integer variable, your program should print appropriate message, stop producing additional Fibonacci numbers and continue with Step 2.

Step 2. Find out the median of numbers in the file Fibonacci by reading its content. The median is the number that has the same number of data elements greater than the number as there are less than the number. Since data in the file is sorted, the median is the middle element of the file, if there are an odd number of elements, or average of the two middle elements, if the file has an even number of elements. In this step you are allowed to use the count of numbers in the file Fibonacci from Step 1.

Step 3. Copy even numbers from the file Fibonacci into the file Fibonacci.even and odd numbers into the file Fibonacci.odd. Write 4 numbers in each row. Also, write on the screen the count of numbers in each file. Find the median in both files and write on the screen.

Step 4. Copy the entire file Fibonacci.even at the end of the file Fibonacci.odd. Write 6 numbers per row. Then print contents of the file Fibonacci.odd (write 5 numbers per row) and the number of elements in the file. In this step you are not allowed to use the count of numbers from Step 1 nor from Step 3.

In this lab, you are not allowed to use arrays.

Sample:

fl1|~/lab> Fibon 20

You entered argument: 20

1. File Fibonacci content:

1 1 2 3

5 8 13 21

34 55 89 144

233 377 610 987

1597 2584 4181 6765

Total: 20 numbers in Fibonacci

2. The Fibonacci median: 72.00

3. Total: 6 numbers in Fibonacci.even

Total: 14 numbers in Fibonacci.odd

Fibonacci.even medium: 89.00

Fibonacci.odd medium: 72.00

4. Total count in Fibonacci.odd is now: 20

1 1 3 5 13

21 55 89 233 377

987 1597 4181 6765 2

8 34 144 610 2584

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Next Generation Databases NoSQLand Big Data

Authors: Guy Harrison

1st Edition

1484213300, 978-1484213308

More Books

Students also viewed these Databases questions

Question

Describe two disadvantages of normalized tables.

Answered: 1 week ago

Question

Question What are the requirements for a SIMPLE 401(k) plan?

Answered: 1 week ago