Chapter One
Chapter One
Abey B. (M.Sc.)
December 2, 2022
What is array
Arrays are used to store multiple values in a single variable,
instead of declaring separate variables for each value.
Array is a data structure which allows a collective name to be given
to a group of elements which all have the same type.
In this type of array, it stores elements in a single dimension.
In this array, a single specification is required to describe elements of
the array.
An individual element of an array is identified by its own unique
index (or subscript).
What is array
An array can be thought of as a collection of numbered boxes each
containing one data item.
The number associated with the box is the index of the item.
To access a particular item the index of the box associated with the
item is used to access the appropriate box.
The index must be an integer and indicates the position of the
element in the array.
1. One-Dimensional Array:
4.3.2. Accessing Array Elements
1. One-Dimensional Array:
4.3.2. Accessing Array Elements
The values of any of the elements in an array can be accessed just
like the value of a regular variable of the same type.
The syntax is:
If declared with less, the remaining elements are set to their default
values (which for fundamental types, means they are filled with
zeroes).
for example:
This creates an array of five int values, each initialized with a value of
zero:
In C++ allows the possibility of leaving the square brackets empty [].
I In this case, the compiler will assume automatically a size for the array
that matches the number of values included between the braces :
Example 1
Example 2
Example 3
Example 4
Example 5
Example 5
Example 5
Multidimensional Array
Example 1:
Multidimensional Array
Example 2:
Multidimensional Array
Example 3:
Multidimensional Array
Example 4: Write the c++ program taking Input from user for Two
Dimensional Array?