(World Population Growth) World population has grown considerably over the centuries. Continued growth could eventually challenge the limits of breathable air, drinkable water, arable cropland and other limited resources. There is evidence that growth has been slowing in recent years and that world population could peak some time this century, then start to decline. For this exercise, research world population growth issues online. Be sure to investigate various viewpoints. Get estimates for the current world population and its growth rate (the percentage by which it is likely to increase this year). Write a program that calculates world population growth each year for the next 75 years, using the simplifying assumption that the current growth rate will stay constant. Print the results in

What will be an ideal response?


```
// Calculate world population over time based on growth.
#include
#include // for setprecision
using namespace std;

int main()
{
// initialize variables; population must be a double because
// int can hold only up to approximately 2 billion
double population, growthRate;

// read values from user
cout << "Enter current population" << endl;
cin >> population;
cout << "Enter growth rate as a percentage" << endl;
cin >> growthRate;

// convert growth rate into growth factor to multiply with population
double growthFactor = growthRate / 100 + 1.0;
int year = 1; // initialize counter
cout << "\nYear\tPopulation\tPopulation Change\n"; // output header
cout << setprecision( 0 ) << fixed; // set floating-point formatting

// loop until year exceeds 75
while ( year <= 75 )
{
double oldPopulation = population; // save old population
population = population * growthFactor; // calculate new population
double difference = population - oldPopulation; // population change

// display information
cout << year << "\t" << population << "\t" << difference << endl;
++year; // increment year
} // end while
} // end main
```

Computer Science & Information Technology

You might also like to view...

Use vim to create a file named fox in the two directory. Use ls to list the name of fox.

What will be an ideal response?

Computer Science & Information Technology

The compiler translates your program into ________ language.

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology

A set of named constants that start with the value 0 for the first constant and increment by 1 for each subsequent constant can be declared as a(n) ________.

a. class b. enum c. enumeration d. None of the above.

Computer Science & Information Technology

A C function must either have parameters or return a value.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology