0% found this document useful (0 votes)
3 views5 pages

Assignment 2

The document explains arrays as a grouping of variables of the same type, with indexing starting from zero. It highlights properties of arrays, including their ability to have multiple dimensions and the method to determine the size of elements. Additionally, it discusses RAM diagrams to illustrate memory allocation before and after code execution for an array of car names.

Uploaded by

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

Assignment 2

The document explains arrays as a grouping of variables of the same type, with indexing starting from zero. It highlights properties of arrays, including their ability to have multiple dimensions and the method to determine the size of elements. Additionally, it discusses RAM diagrams to illustrate memory allocation before and after code execution for an array of car names.

Uploaded by

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

QUESTION 1

1. SHORT NOTES ABOUT ARRAYS


An array: is the grouping of variables of the same type into
blocks of memory.
consider you have to store three cars in the parking, the
suitable way to store these cars in variables is:

Therefore the output will be:

Thus the array “cars” is used to group the cars in the parking.
NB:
Indexing of an array starts from 0. This means the first element
Is stored at the 0th index, the 2nd at the 1st ,and so on.
SOME PROPERTIES OF ARRRAYS
 An array can have multiple dimensions.
 Indexing of an array starts from zero.
 It is a collection of data of the same data type.
 We can find the size of the type of elements stored by
subtracting adjacent addresses.
QUESTION 2
To modify the example in the book, such that you rename the
variable to my mother’s name, and enter the data into the
array.
Code for an array is shown in the figure below.
The output after the code execution is shown on the figure
below
QUESTION 3
Required to use the RAM diagrams to show that program is
running or being executed in the computer. The following are RAM
diagrams to show code execution of the array.
Before the code is written the RAM diagram is as shown below
FREE

FREE

FREE

FREE

FREE

FREE

FREE

This is to show that there is no any variable declared, thus every cell of
the computer memory (RAM) is free.
After the writing the code , the computer is instructed to reserve
spaces for the array that has a finite number of variables.
Thus for our case the RAM diagram is shown as following diagram,

RESERVED
RESERVED
RESERVED
RESERVED
RESERVED
FREE
FREE

The reserved spaces are reserved for the array containing five variables.
Thus after the code execution the output can be expressed on the RAM
diagram as shown below.
Mercedes

Escalade

G Wargon

Blade

Chevrolet

FREE

FREE

You might also like