Example 20: Wolf and Rabbit Population
Explore how to model ecological population changes of wolves and rabbits using loops in C. Understand how to apply formulas for growth and decline over 100 days and print population data at intervals. This lesson improves your ability to implement ecological simulations with control flow in C programming.
We'll cover the following...
We'll cover the following...
Problem
Consider an ecological simulation of wolf and rabbit populations. Rabbits eat grass while wolves eat rabbits. There is plenty of grass, so wolves are the only obstacle to the rabbit population increase. The wolf population increases with the population of rabbits. The following formulae can express the day-by-day changes in the rabbit population R and the wolf population W:
...