/* * File: worldPop.cpp * Purpose: * Estimate the world population growth in a year and * also per day. * Given that on January 1, 2008 the world's population was * estimated at 6,650,000,000 and the estimated growth is * at the rate of +1.14% */ #include using namespace std; int main() { double population = 665.0; double growthRate = 1.14 / 100.0; double growthInOneYear = population * growthRate; double growthInADay = growthInOneYear / 365; cout << "World population on January 1, 2008 is " << population << endl; cout << "By Jan. 1, 2009, it will grow by " << growthInOneYear << endl; cout << "An average daily increase of " << growthInADay << endl; double current_pop = population; int years = 0; while( current_pop < 1000000 ) { current_pop = current_pop * 1.14; //shorter form current_pop *= 1.14 //short form for self adding += //short form for self subtracting -= years++; } cout << "Number of Years: " << years << endl; return 0; }