/*********************************************************** birth-deathrate.ch Populations Word Problem Use this program to help students determine how long it will take to reach a certain target population, given a starting population, birthrate, and death rate. Have students analyze, fill in parts of, or use the program to check results to exercises they are already working on ************************************************************ Copyright 2014 SoftIntegration Inc. http://www.softintegration.com Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 ***********************************************************/ // constants are predefined here #define POPULATION 10000000.0 #define BIRTHRATE 0.015 #define DEATHRATE 0.023 #define REDUCTION 0.1 // initialize variables used for program int current_pop, target_pop, years, change_pop; current_pop = POPULATION; target_pop = POPULATION * REDUCTION; years = 0; change_pop = 0.0; // Determines the number of years to reach the target population while (current_pop >= target_pop) { change_pop = (current_pop * BIRTHRATE) - (current_pop * DEATHRATE); current_pop = current_pop + change_pop; years = years + 1; } // Prints the answer printf("Number of years until target population reached: %d\n", years);