Converted Text (4)
Converted Text (4)
Definition:
An array is a data structure that stores a fixed-size sequential collection of elements of the same
data type.
Features:
Fixed size: Size is defined at the time of declaration and cannot be changed.
Types of Arrays:
1.
One-Dimensional Array (1D):
3.
Multidimensional Array:
cpp
CopyEdit
datatype arrayName[size];
Example:
cpp
CopyEdit
int numbers[5]; // Declaration int numbers[5] = {10, 20, 30, 40, 50}; // Initialization
Common Operations:
Operation Description
Traversal Accessing each element of the array
Insertion Adding an element at a specific position
Deletion Removing an element from a specific position
Searching Finding the index of a given element
Updating Modifying an element at a given index
Advantages:
Disadvantages:
Fixed size.
Use Cases:
Lookup tables.