array in c++ / review. an array contains multiple objects of identical types stored sequentially in...

Click here to load reader

Upload: curtis-parks

Post on 18-Jan-2018

242 views

Category:

Documents


0 download

DESCRIPTION

Like a regular variable, an array must be declared before it is used. A typical declaration for an array in C++ is: type name [ no of elements]; You can create an array from any type with the exception of some special types. An array always occupies a contiguous memory space. To know how much memory spaces an array needs, for example, if we have an array of 10 elements, this space is 10*sizeof(float) = 40 bytes.

TRANSCRIPT

Array in C++ / review An array contains multiple objects of identical types stored sequentially in memory. The individual objects in an array, referred to as array elements, can be addressed using a number, called index or subscript. The array is the most commonly used data storage structure. It helps us to see how object-oriented programming and data structures relate to each other. Like a regular variable, an array must be declared before it is used. A typical declaration for an array in C++ is: type name [ no of elements]; You can create an array from any type with the exception of some special types. An array always occupies a contiguous memory space. To know how much memory spaces an array needs, for example, if we have an array of 10 elements, this space is 10*sizeof(float) = 40 bytes. when declaring an array, there is a possibility to assign initial values to each one of its elements. To access the values of an array; being able to both read and modify its value by using this format : name[index] # include using namespace std; int main() { int n[10]; for( int i=0;i