Zoo tutorials: [ SQL | Linux | XML ]
ProgZoo: [ Java | C# | VB | C++ | Perl ]
Log in

A Gentle Introduction to
Programming

Tutorial: More than one accumulator

 
In these examples we accumulate more than one value. We still only need one loop - we just do more work in each.

1. Average population


Big

Calculate the average population size for the countries of the world.

Print the total population by the number of countries.

How to use an accumulator

2. Is 3 million the median?


Big

Show the number of countries with a population more than 3000000

Show the number of countries with a population less than 3000000

3. USA and the world


Big

Show the GDP of "United States" as a percentage of the world GDP.

How to calculate