A structured collection of components, all of the same type, that is given a single name. Each component is accessed by an index that indicates the component's position within the collection.
type identifier[const int expression];
The data needs to be stored because it will be used multiple times.
The programmer may observe no ill effects. Ie the values retrieved or the memory overwritten does not cause an error in the computation.
The programmer may observe "strange" results in computation based on the data incorrectly retrieved or written to.
The program may crash due to an attempt to access memory outside of that available to the program.
size_t size; cout << "Enter the array size "; cin >> size; cout << endl; int ary[size];
const size_t MAX_SIZE =10; int main() { int ary2[MAX_SIZE]{0}; size_t i; for(i =0; i <= MAX_SIZE; i++) { cout << ary2[i] << " "; } cout << endl;
For each position in the array starting at the first Move the smallest number in the remaining array to this position.
bool CheckArray(const int array[], size_t size) {
bool CheckArray(const int array[], size_t size) { size_t i=0; bool good = true; while (good and i < size-1) { if (array[i] > array[i+1]) { good = false; } i++; } return good; }
Selection sort is $O(n^2)$
An $O(n^2)$ algorithm has each piece of data interact with every other piece of data.
int Fibonacci(int limit){ int old = 1; int current = 1; int sum = 1; int i; for(i = 2; i <= limit; i++) { sum = old+current; old = current; current = sum; } return sum; }
This can be used to support information hiding.
It makes it possible to reuse code more easily.
The compiler proper translates high level c++ code into machine language. This produces object files.
The linker combines object files and system library files into an executable.