ARRAY in C++
Why, When and How to use array
What is an Array
An array is a collection of elements with similar
data type.
– Element are identified by an index or a key.
– Store values in contiguous fashion.
EX.
4 6 3 5 8 8 9
Arr
0 1 2 3 4 5 6
index
value
Declaring an Array
• Syntax
dataType arrayName[size] ;
Example :
Defining an Array
dataType arrayName[ ] = { V, A, L, U, E, S} ;
Accessing Elements
• Array allows random element access with a
integer index.
• Syntax
arrayName[index] = value ;

ARRAY in C++. Why, when and how to use array

  • 1.
    ARRAY in C++ Why,When and How to use array
  • 2.
    What is anArray An array is a collection of elements with similar data type. – Element are identified by an index or a key. – Store values in contiguous fashion. EX. 4 6 3 5 8 8 9 Arr 0 1 2 3 4 5 6 index value
  • 3.
    Declaring an Array •Syntax dataType arrayName[size] ; Example :
  • 4.
    Defining an Array dataTypearrayName[ ] = { V, A, L, U, E, S} ;
  • 5.
    Accessing Elements • Arrayallows random element access with a integer index. • Syntax arrayName[index] = value ;