previous | start | next

## Using Vectors to Collect Data Items

- Suppose you write a program that read in a list of salary figures and prints the list, marking the highest value, like this:

  >     32000
  >     54000
  >     67500
  >     29000
  >     35000
  >     80000
  >     highest value => 115000
  >     44500
  >     100000
  >     65000

- All the values need to be read to find the highest one.
- If you know there are ten inputs, you could use 10 variables `salary1`, `salary2`, ... , `salary10`. But you would have to write a lot of code ten times to handle each variable.
- This technique becomes prohibitive as the list gets larger (100 salaries).

previous | start | next