Non-recursive fibonacci

Assignment Help Basic Computer Science
Reference no: EM131291626

Non-recursive Fibonacci

The Fibonacci sequence is 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, ...

(The first term is 1. The second term is 1. Each term thereafter is the sum of the previous two terms.)

Write a C program that contains a function called fibonacci. This function, when given an integer n >= 1, will return the nth Fibonacci number. The function should use a non-recursive,iterative strategy. The main function should provide the user with a menu of two choices:

1- Calculate Fibonacci

2- Exit

(Enter 1 or 2)

If the user enters a choice different from 1 or 2, your program should detect the invalid choice,and re-prompt the user to enter a new valid choice. If the user picks choice 1, your program should prompt him/her to enter an integer number greater than 0. This number is first validated by the program, than function fibonacci is called, and the result is displayed to the user.The menu is continually displayed until Choice 2 is entered by the user. Use a switch statement for controlling the menu.

Reference no: EM131291626

Questions Cloud

Field of modern security : Write a 700- to 1,050-word paper in which you compare how technology has affected the field of modern security over the last 20 years.
How you feel that ethics will impact on your it career : How you feel that ethics will impact on your IT career. Write also the ethicaltheory which can be the best to guide your behaviors. Also, including the goals and situations that you may face.
Labsim testout security pro : Please log into LabSim TestOut Security Pro and complete all labs and end of chapter exams in Chapter 7. There is NO TIME LIMIT to complete these labs and you may try them more than once.
Applying skills learned : From the e-Activity, explain what you learned about the Website you selected by looking at the source code. (i.e., the version of HTML that was used, comment tags, if the head elements were marked, and if so, the type of information they contained..
Non-recursive fibonacci : Write a C program that contains a function called fibonacci. This function, when given an integer n >= 1, will return the nth Fibonacci number. The function should use a non-recursive,iterative strategy. The main function should provide the user w..
How will you transfer these new skills : How will you transfer these new skills and the information gained to your workplace?What methods did you find to better understand the Coding Guidelines that you identified as difficult or challenging in this week's discussion?
Explanation on visual logic with the question : Design a class named Automobile that holds the vehicle identification number, make, model, and color of an automobile. Include methods to set the values for each data field, and include a method that displays all the values for each field. Create ..
Identify at least 5 issues to be addressed by management : After reading the attached "canadian Solar" case, Identify at least 5 issues to be addressed by management and to do a one-page summary of the issues for given case.
Discuss the concept of selection in terms : Discuss the concept of selection in terms of what we perceive. Try to think of examples of how you have engaged in selective exposure, selective perception and or selective memory. How has this perhaps skewed your views of the world?

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Compare the conventional and renormalized som algorithms

Compare the conventional and renormalized SOM algorithms, keeping in mind the following two issues:

  Explaining social network widgets and resaurant locators

The popularity of Apple's iPhone and Application store has made _____ improtant to advertisers, who see social network widgets, resaurant locators.

  Converting each of the forms of to relational algebra

Give a rule for converting each of the following forms of to relational algebra. All conditions may be assumed to be applied (by a two-argument selection) to a relation R. You may assume that the subquery is not correlated with R. Be careful that ..

  What can we say about the relative prices of a and b today

Let S, be the price of a non-dividend-paying stock. Suppose derivatives A and B pay functions f and g of the stock price at expiry.

  Discuss backup plans and any devices that you use

In this week's discussion, discuss what you think you should do to protect your work on the computer. Discuss backup plans and any devices that you use for the backup of your information.

  Problem regarding the osi network

For this network design assignment, you are free to come up with a fictional mid sized company engaged in a dot-com business for which you will select the business focus.

  Studying any of the three languages

How many students are not studying any of the three languages?

  How long is a nanoyear in seconds

Here are some questions for practicing unit conversions: (a) How long is a nanoyear in seconds? (b) Micrometers are often called microns. How long is a megamicron?

  Selection of right type of compensation agreement

How can the selection of the right type of compensation agreement save money?

  Takes non-negative integer

Then implement function drawLevy() so it takes non-negative integer n as input and draws the levy curve Ln using instructions obtained from function levy(). Don't forget doc strings and comments.

  What obstacles to successful implementation might arise

Utility Rebates Have publicly regulated electric companies provide "rebates" of 75% of the purchase price to consumers who install LED bulbs. Allow utilities to cover the cost of the program through higher electricity rates.

  What is the result of issuing 0x08 function code

In a SCADA system, what is the result of issuing 0x08 function code followed by a 0x01 subfunction code on a slave using Modbus?

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd