Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1 (18 points) int bunnyEars(int n ) returns 1 if n is less than 0 , otherwise returns the number of ears for n bunnies.

image text in transcribed

1 (18 points) int bunnyEars(int n ) returns 1 if n is less than 0 , otherwise returns the number of ears for n bunnies. 2. (18 points) int factorial(int n ) returns 1 if n is less than 0 , otherwise returns the factorial of n 3. (18 points) int fib(int n ) returns 1 if n is less than 0 , returns 0 if n is 0 , returns 1 if n is 1 , otherwise returns fib of n - 1 plus fib of n - 2. (If you test this with numbers greater than about 50 , it will be very slow.) 4. (18 points) int posPow(int base, int exp) returns 1 if exp is less than 0 , otherwise returns base raised to the power exp. 5. (18 points) int numDigits(int n ) returns the number of digits in n. Hint: in C, as in Java, int division returns an int; any digits that would be after the decimal point are lost, so that, for example, 5/4 is 1. 6. (10 points) Write a main() that tests all the other functions thoroughly. Turn in your code and a .txt file with a copy and paste of the output from running your program

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

Securing SQL Server Protecting Your Database From Attackers

Authors: Denny Cherry

2nd Edition

1597499471, 978-1597499477

More Books

Students also viewed these Databases questions