QP7 - Although it's not necessary, you may make your menu...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Quiz Program #7 Program Description: Fibonacci and Factorial with functions The Fibonacci sequence was described in the previous quiz program. The factorial of a number is defined as follows: n! = 1x2x3x4x. ..xn. Also, 0! = 1. Write two functions that calculate the n th Fibonacci and factorial numbers. They should have the following two prototypes: int fib(int n); int fact(int n); Also, write a function that prints out a menu (that allows the user three choices – 1)Calculate Fibonacci, 2) Calculate Factorial, 3) Quit), reads in, and returns the user's choice. The prototype of this function should be: int menu(); Use these functions to create a program that prompts the user with the menu and then executes the user's option, and continues this sequence until the user chooses to quit.
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Although it's not necessary, you may make your menu function so that it continues to reprompt the user until they enter a valid menu entry. Sample Run (User input in bold and italics) Please select one of the following menu options: 1) Calculate a Fibonacci number. 2) Calculate a factorial. 3) Quit 1 What Fibonacci number do you want to calculate? 8 The 8 Fibonacci number is 21. Please select one of the following menu options: 1) Calculate a Fibonacci number. 2) Calculate a factorial. 3) Quit 2 What factorial do you want to calculate? 7 7! = 5040. Please select one of the following menu options: 1) Calculate a Fibonacci number. 2) Calculate a factorial. 3) Quit 3...
View Full Document

Ask a homework question - tutors are online