Question: C program Exercise 2 Exercise Objectives: Calling functions recursively Comparing the iterative approach vs. the recursive approach Problem Description A cell type might split into
C program
Exercise 2
Exercise Objectives:
- Calling functions recursively
- Comparing the iterative approach vs. the recursive approach
Problem Description
A cell type might split into two or three every hour, or might die. The likelihood for splitting into two is 30% and into three is 55% and dying is 15% for every lifespan. Assume that we start with a sample of one cell, write a recursive function to calculate and return the total number of cell after a number of hours. The function receives the umber of hours as a parameter.
Hint: use rand() function to simulate the percentage.
Use this function signature: int cell(int total_hours).
The function should stop when the total_hours left is 0 or less.
Write the main function that prompts the user to enter the number of hours and pass the number of hours to the recursive function cell. Then print the result returned by the recursive function
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
