Reflection: Array
I, Summary
A data structure is a collection of data types designed to store information in some optimal way. The simplest example of a data structure is an array.
dataType arrayIdentifier[ size ] = { value, ... , value };
A data structure is a collection of data types designed to store information in some optimal way. The simplest example of a data structure is an array.
The fundamental unit of an array is an element. Each element holds has an index and holds one data value.
Index numbering starts at 0 and extends to one less than the size of the array. To refer to an element, we use the array name followed by bracket notation around the element index.
dataType arrayIdentifier[ size ] = { value, ... , value };
II, Applied to solve problems
A,Write program
1. Declare an double array with max 100 elements
2. Input an positive integer n that indicated the number of element of array
3. Input n elements of array
4. Display array has just been inputted
5. Calculate sum of all elements, sum of odd element, average of even elements, average of element at odd index
Source and demo:
file source: array.cpp
B, Propose your array sample
III, Some of my thoughts
When I used array, it's so convenient. I don't use much variables because I can use array with index, it's easy-to-use. But I have some mistake with array of pointer, it's so hard with me. Arrays are important to C and should need lots of more details. There are following few important concepts related to array which should be clear to a C programmer.
Comments
Post a Comment