Array in c++ programming
Array
To declare an array
syntax:-
Datatype arrayname[size];
To initialization an array
![]() |
Array initialization |
Important points about array
- The address of first element is called base address ab array.
- Array name represent base address of an array .
Ex-48252
- This is a unique no used to access an element in an array is know as base address of array.
- The index of first element is always zero (0) an array.
- The index of last element is always one less of array size.
Size of array= 5.
Last index of array=5-1=4. - The positive of element in a array always once more it's index.
Index of 45=1.
Position of 45=2.
Access an element
- set value.
- get value.
set value
syntax
int a[2]={10,20};get value
syntax
int a[2];
cout<<a[2];
cout<<a[2];
Operation an array
- Input.
- Output.
- Searching.
- Sorting.
- Insertion.
- Deletion.
- Merging.
There are two types of array
- Single dimensional array
- Double dimensional array
Comments
Post a Comment
If you have any doubt. Please comment me know.