C++ program that defines a structure to hold several items of related data about a place.
Created by Phil Gardner
last edited Mar 16 2021 by Phil Gardner
Searches through the 1D array to find all places in Europe, then finds all places with a population > 5 million.
The details of each place are held in a single structure.
The search iterates through each structure in the 1D array, examining the value in a particular field.
Compiles on Raspberry pi, Apple Mac or Linux PC, but you can paste into replit.com website too.
Stop press:
Second version added that searches for all places in Australia, all places in the UK, all places outside the UK.
Third version also counts up the number of matches found during each linear search and displays this.
Gave this to Year 11 and asked them to add extra records, as well as their own kinds of search using various fields and operators to solve typical search problems.
Content: structures, fields, data-types, 1D arrays, linear search, relational operators.
Feedback and Comments
Available when logged in (join via the front page, for free):