Computer Science 1037A/B Lecture Notes - Lecture 1: Dynamic Array, Segmentation Fault, Selection Sort

29 views5 pages

Document Summary

A systematic arrangement of similar objects, similar objects have the same data types. Each object is assigned a unique index, and the size of the array is often fixed at declaration. C++ requires that the array size used to declare an array must be a constant int size = 4; double mylist[size]; //wrong cause size isn"t const const int size = 4; double mylist[size}; //correct. For an array with size ten, array[9] would be the last element while 0 is the first element. C++ doesn"t check the an array"s boundary, so if size is 10, a memory access violation will occur if you try and call mylist[-1] or mylist[10] Datatype arrayname[size] = {value0, value1, , valuek}; double mylist[4] = {2, 3. 9, 4. 5, 6}; Same as: double mylist[4]; mylist[0] = 2; mylist[1] = 3. 9; mylist[2] = 4. 5" mylist[3] = 6; Initializing arrays with random values for( int i = 0; i

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents