Write a c program that contains a function called fibonacci


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.

Solution Preview :

Prepared by a verified Expert
Basic Computer Science: Write a c program that contains a function called fibonacci
Reference No:- TGS01694353

Now Priced at $20 (50% Discount)

Recommended (91%)

Rated (4.3/5)