Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Complete the implementation of the fibonacci function. This activity will help you learn how to use counter controlled loops, arrays, global variables, and carry out

image text in transcribedimage text in transcribed

Complete the implementation of the fibonacci function. This activity will help you learn how to use counter controlled loops, arrays, global variables, and carry out operations involving simultaneous access to multiple elements of a single array. is program populates array seq with the first 34 terms of a Fibonacci like sequence, starting rom initial seed values seq 0 alues which are supplied to the program via standard input. = X, seq = Y, where and Y are integer general design of your program is as follows .Global variables: o seq: an array with capacity to hold 34 values of type int. o fibonacci expects no arguments o fibonacci produces no result (i.e. the return type is void). o Read two integer values from standard input, and store then in the first two elements of the array, in the order they are received. Parameters: . Returns: . Process: - Standard library function scanf may used for this Do not emit any kind of prompt; this program will not be executed interactively purpose -If it makes you feel more comfortable, you can display a prompt. It will be ignored by AMS The values supplied when AMS tests your program are guaranteed to be valid integers, separated by spaces, with values between 1 and 30 inclusive Error detection or input validation is not required for this exercise o Populate the remainder of the array with the consecutive terms of the Fibonacci-like sequence grown from the seed values. To do this, use a counter-controlled loop which will visit every element of seq from the third to the last. The Fibonacci term at position is equal to the sum of the terms at positions (1-1) and (t-2). .Test plan o Test your program with several seed pairs, including: (1,1), (30, 30), and some pairs involving intermediate values such as (3,9) o Verify the correctness of your results by computing a few terms by hand, or by some alternate but reliable method such as a spreadsheet program. o Use input redirection to supply data to the standard input stream of your program. There are several ways to do this. " One easy way is to pipe the output of the echo command into your program. For example, to send a single line containing the seed pair (5,9) to the test driver, use the following command echo -n "5 9" ./fibonacci . A program similar to yours produces the output sequences pictured below. The images illustrate a convenient way to invoke the test driver using input redirection to provide the seed values for reading via scanf. Your results will not be exactly the same as this view, because each user gets a unique set of parameters. However, it should give you an idea what to aim for bash $echo -n " 1"/fibonacci 5 8 13 21 34 89 144 233 377 610 987 1597 2584 4181 6765 10946 28657 bash $echo -n "1 10" fibonacci 1e 21 32 53 85 138 223 361 584 945 1529 2474 4003 6477 10480 16957 27437 44394 1831 116225 188056

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

Advanced Database Systems For Integration Of Media And User Environments 98

Authors: Yahiko Kambayashi, Akifumi Makinouchi, Shunsuke Uemura, Katsumi Tanaka, Yoshifumi Masunaga

1st Edition

9810234368, 978-9810234362

More Books

Students also viewed these Databases questions

Question

Which form of proof do you find least persuasive? Why?

Answered: 1 week ago