This is an exercise where we need to use modules ( this is alsocalled methods-a
ID: 3615264 • Letter: T
Question
This is an exercise where we need to use modules ( this is alsocalled methods-a method is a program module that contains a seriesof statements that carry out a task) ( A method must include aheader (also called the declaration or definition,a body and a return statement). We are notworking in specific language, but in the text that we are using themodule name is followed by a set of parentheses.
First of all, what I want a module to calculate and display aFibonacci series. The 26 and 270 make up a range of numbersto help you control the loop.
A Fibonacci series starts with two numbers (typically 0 and 1 -and notice they're consequtive numbers). Add those twonumbers together and get a third number. The pattern THEN isto REPEATEDLY, drop the first, store the second number in thefirst, store the third number in the second and add again to get anew third number. Somewhere, based on my instructions, inthat repetition, you need to write out one of the numbers (some usethe first number, some use the third number). DON'T STORE THENUMBERS IN AN ARRAY.
We do not need to know the actual numbers in the seriesbeyond the two initializing values. And, if we wrote themodule using parameters, we would pass IN the starting valueand the maximum range value - so we wouldn't even know thosevalues.
Is it NOT necessary to write the complete algorithm,just the module.
Explanation / Answer
please rate - thanks hope this helps-everyone does pseudocode a little differently--if something might not be clear I tried elaborating onit in parenthesis fib(min,max) (where min=26 and max=270) setfirst to 0 setsecond to 1 loop: next=first+second next>max yes: return to calling program next>= min yes: output next setfirst tosecond (first=second) set second tonext (second=next) goback to loop
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.