0% found this document useful (0 votes)
18 views2 pages

Topic 9

Uploaded by

Erick Waweru
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views2 pages

Topic 9

Uploaded by

Erick Waweru
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

8.

0 Arrays
 Many applications require the processing of multiple data items that have common
characteristics.
 An array is a collection of homogeneous data items.
 The individual data items can be characters, integers, floating point numbers etc. However, they
must be of the same type.
 Secondary data type which is indexed
 Each array element is referred to by specifying the array name followed by one or more
subscripts (thus arrays are sometimes referred to as subscripted data type), with each subscript
enclosed in square brackets.

X
10 20 30 40 50 …

X[0] X[1] X[2] X[3] X[4] …

 X is a one dimensional array, X is the name of the array


 In most programming languages, Array indexing starts from zero(0)
 X[i] refers to the ith element of array X
 In a two dimensional array, X[i][j] is the element at row i, column j.

8.1 Defining an array


 Arrays are defined in much the same manner as ordinary variable, except that each array
name must be accompanied by a size specification(maximum number of elements)
 Example
data type array_name[expression]
eg int X[100] - X is an array of integer numbers with a maximum size of 100 integer
numbers.
 Operations that can be performed on arrays( i.e created array) :
 Traversing
 Insertion
 Deletion
 Search
 Update
 Sort
 merge

8.2 Multidimensional Array


 A two dimensional array requires two pairs of square brackets, a three dimensional array will
require three pairs of square brackets and so on.
 Multi dimensional arrays are defined in much the same manner as one dimensional array.
 Example
 int matA[20][15], matB[20][15]
 double records[100][66][255]
9.0 Structures
 Consists of heterogeneous data items.
 A single structure might contain integer elements, floating – point elements and character
elements
 Individual structure elements are referred to as members.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy