Intrd To Array + Single Array T.abduLMALIK
Intrd To Array + Single Array T.abduLMALIK
Introduction to Array
Adjectives of this unit
- What Is Array ?
- Advantage And Disadvantage Of Array .
- Types Of Array .
- Declaration Of Array .
- Example Of Array.
Multidimensional array.
(Array of arrays )
One dimensional array “ single array”
In this type of array, it stores elements in
a single dimension. And, In this array, a
single specification is required to describe
elements of the array.
Declaration of One Dimensional Array
To declare an array in C++, you need to
define
- The data type of elements in the array
- The name of the array
- The size of the array
Syntax:
Data_type Array_Name [size];
Note :
size of array is any positive integer or
constant variable.
Example
For Example:
define SIZE =7
int score[SIZE];
Suppose, we have array int score[7] as shown in below
figure:
Initializing One Dimensional Array
we can initialize one-dimensional array at compile
time and at run time.
Compile Time Initialization:
Arrays can be initialized at the time they are declared.
This is also known as compile-time initialization.
- int std[5]= {1,2,3,4,5}
1 2 3 4 5
std0 std1 std2 std 3 std4
- int std[5]={1,2}
1 2 0 0 0