CAS Community   >   Resources   >  

Program! Searching through a 1D array of structures (GCSE)

C++ program that defines a structure to hold several items of related data about a place.

Phil Gardner

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 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.

Downloaded 155 times.


This resource has attached files: to access these files, please tick the box below to assent to the license terms
License: The resources on CAS website are under Creative Commons Attribution-Share Alike 3.0 licence unless otherwise specified by the resource creators.

You must confirm that you have read and agree the licence's ToS before you can download the attachments of this resource.

I have read the licence agreement of this resource and agree to abide by its terms and conditions.

Feedback and Comments

Available when logged in (join via the front page, for free):
  • View 0 comments on this resource.
  • View resource history, links to related resources.
  • Leave feedback for the author(s), or help by editing the resource.

All Rights Reserved © Computing At School 2021
Using the websiteDisclaimer of liabilityCookies policyPrivacy notice