CIE IGCSE COMPUTER SCIENCE
Practical problem-solving and programming
Chapter 12 – Data structures: arrays and using pre-release material
12.1 Introduction
One of the advantages of using computer systems is their ability to accurately repeat the same task many
times, for example, producing electricity bills or calculating exam scores. In order to do this, programs are
written with loops for repetitions to work with lists of similar items.
These lists are identified by the use of a single name and each item in the list can be found by an index
number showing the place in the list. This type of list is called a one-dimensional array. The items in the list are
the elements of the array.
12.2 Arrays
12.2.1 One-dimensional arrays
In order to use a one-dimensional array in a computer program, consider:
what the array is going to be used for, so it can be given a meaningful name
how many items are going to be stored, so the size of the array can be determined
what sort of data is to be stored, so that the array can be appropriate data type.
For example, if a one-dimensional array for all the students’ test marks in a class was to be set up:
array name StudentMarkTest
number of items = number of students in the class, this could be a constant NoStudents
whole numbers need to be stored, data type Integer.
Arrays usually start at element 0 or element 1. Often if an array starts at element 0, the size of the array is
given as one more than required and element 0 is not used.
1
, Above is array declaration in JavaScript.
Above is declaration of lists and arrays in Python.
12.2.2 Using a variable as an index in an array
In order to repeat the same task many times for all the items in a list, each item needs to be referred to in the
same way using the index number for each element of the one-dimensional array. If a variable is used for this
index number, then the same code can be re-used for each item.
This allows several arrays to be used together with the same index number to show related information, for
example, each student could sit more than one test and the name and gender of the student could also be
recorded.
2
The benefits of buying summaries with Stuvia:
Guaranteed quality through customer reviews
Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.
Quick and easy check-out
You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.
Focus on what matters
Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!
Frequently asked questions
What do I get when I buy this document?
You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.
Satisfaction guarantee: how does it work?
Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.
Who am I buying these notes from?
Stuvia is a marketplace, so you are not buying this document from us, but from seller anyiamgeorge19. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy these notes for $11.99. You're not tied to anything after your purchase.