Answered step by step
Verified Expert Solution
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.
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started