Table of Contents
ToggleAn array is a homogeneous
collection of items, where “homogeneous” denotes that each element in
the array has the same data type. The array value is kept at the address
specified by an index, which is a memory location.
Certainly, here are the
points presented individually:
Homogeneous Collection:
An array is a collection of
homogeneous elements, meaning they all have the same data type. Here’s an
example of an array of integers:
int myArray [4]; // An
array of integers with four elements
Non-Singular:
Unlike singular variables, an array is not a
single value but rather a container for multiple elements of the same data
type.
int singleValue = 42; //
Singular variable
int myArray [3:0]; // Array with four elements
Unified Entity:
Arrays provide a convenient
way to manage multiple data variables as a single entity, making it easier to
handle related data collectively.
string names [3]; // Array
of strings to store names
names[0] =
“Alice”;
names[1] = “Bob”;
names[2] =
“Charlie”;
With this array, you can easily handle multiple names
together.
It’s important to note that
you cannot assign a value to an entire array as a whole; you must access and
manipulate individual elements.
int myArray [4]; // Array
of integers
myArray[0] = 10;
myArray[1] = 20;
myArray[2] = 30;
myArray[3] = 40;
You set each element of the array
separately.
Types of arrays
Packed
Array
Unpacked
Array
Static
Array (Fixed Array)
Dynamic
Array