What is an array?

What is an array?

An array is a collection of variables of the same type that are referred to through a common name. A specific array element is accessed by an index. In C++ arrays consist of contiguous memory location. The lowest memory address corresponds to first element and the highest to the last element of the array. Arrays could be single dimensional or multi dimensional. A string is most common example of an array. It is a single dimensional array of characters.
- The general form for declaring a single dimensional array is :
type var_name[size];
type is data type
var_name is name given to the array variable
size is size of the array;
Example :
int a[10]; declares an array of 10 integers.
- Array indexing starts from 0. To access nth element of an array (n-1)th index is to be used. i.e. a[3] = 5; will assign value 5 to the 4th element of array.
Define pointer and array. Explain the difference between them - C++
Define pointer and array. Explain the difference between them - A pointer is a variable that holds a memory address. This address is the location of another object (typically, a variable) in memory....
What is Dynamic memory management for array?
What is Dynamic memory management for array? - Using the new and delete operators, we can create arrays at runtime by dynamic memory allocation.....
What is C-string? - C++
What is C-string? - C-string is null terminated string which is simply a null terminated character array......
Post your comment