Year 11 Exam  >  Year 11 Notes  >  Computer for GCSE/IGCSE  >  Arrays

Arrays | Computer for GCSE/IGCSE - Year 11 PDF Download

1D Arrays

A one-dimensional (1D) array is a collection of elements that are all of the same data type. It allows you to store a sequence of values under a single variable name.

  • In pseudocode, you declare a 1D array using the syntax: DECLARE arrayName[n] OF dataType. For example, DECLARE numbers[5] OF INTEGER.
  • When working with Python, you declare a 1D array like this: array_name = [0] * n. For instance, if you want to create an array of 5 zeros, you write: numbers = [0] * 5.
  • In Java, you declare a 1D array using the syntax: dataType[] arrayName = new dataType[n]; An example would be: int[] numbers = new int[5].
  • For Visual Basic, the syntax to declare a 1D array is: Dim arrayName(n) As dataType. For instance, Dim numbers(4) As Integer creates an array 'numbers' with 5 integer elements.

Accessing elements in a 1D array involves using the index, which typically starts at 0 for the first element. For example, if 'numbers' is an array declared in Python, numbers[0] would refer to the first element.

2D Arrays

A two-dimensional (2D) array is a grid-like structure consisting of arrays within an array.

  • To define a 2D array in pseudocode: DECLARE arrayName[n][m] OF dataType
  • In Python: array_name = [[0] * m for _ in range(n)]
  • In Java: dataType[][] arrayName = new dataType[n][m];
  • In Visual Basic: Dim arrayName(n, m) As dataType

Accessing elements in a 2D array involves specifying a row index and a column index.
The method for element access is consistent across languages, utilizing square brackets:

  • [i] for 1D arrays
  • [i][j] for 2D arrays

The document Arrays | Computer for GCSE/IGCSE - Year 11 is a part of the Year 11 Course Computer for GCSE/IGCSE.
All you need of Year 11 at this link: Year 11
92 docs|30 tests

Top Courses for Year 11

92 docs|30 tests
Download as PDF
Explore Courses for Year 11 exam

Top Courses for Year 11

Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev
Related Searches

past year papers

,

Exam

,

ppt

,

Semester Notes

,

Sample Paper

,

Arrays | Computer for GCSE/IGCSE - Year 11

,

Objective type Questions

,

Viva Questions

,

MCQs

,

pdf

,

Previous Year Questions with Solutions

,

Important questions

,

shortcuts and tricks

,

practice quizzes

,

Arrays | Computer for GCSE/IGCSE - Year 11

,

video lectures

,

Extra Questions

,

study material

,

Free

,

Summary

,

Arrays | Computer for GCSE/IGCSE - Year 11

,

mock tests for examination

;