Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 9

ARRAY IN C++

Sarhad Rasool Abdullah

6-Jun-2024
WHAT IS ARRAY?
 An array is a group of consecutive memory locations
with same name and data type.

 Simple variable is a single memory location with


unique name and a type.

 The elements of array is accessed with reference to its


position in array, that is call index or subscript.
DECLARATION OF AN ARRAY:
Like a regular variable, an array must be declared before it is
used. A typical declaration for an array in Visual C++ is:

type name [elements];


 type is a valid type (like int, float...)
 name is a valid identifier
 elements field (which is always enclosed in square
brackets []), specifies how many of these elements
the array has to contain.
○ INT NUM[6]

size of the
array
Base name of
type array
ADVANTAGES OF ARRAY:
Arrays are used to process many value easily
and quickly.
The values stored in an array can be sorted
easily.
The search process can be applied on arrays
easily.
Arrays can store a large number of value with
single name.
EX. PROGRAM:
TYPES OF ARRAY:

1 2 3

Single dimensional
Two dimensional array Multi dimensional array
array
SORTING ARRAYS:

1 2

ASCENDING DESCENDING
THANKS

You might also like