Arrays

elements that are each the same size and data type || int numArr[] || p. 328 || int numArr[3]
 * Topic || Definition || Code || Refrence page ||
 * Arrays || a contiguous block of memory cells, made of
 * Declare Arrays || creating an array and adding values to it || declaration

adding values numArr[0] = 2 numArr[1] = 6 numArr[2] = 12

or int numArr[] = {2,6,12} || p 330-331 || add them to the variable sum.
 * Using an Array in a loop for summation || uses a loop to to access each element and

to the right shows how to do a summation for the array num, who has 5 elements. For use in your program, substitute the name of your array i​n for num, and the size of yoru array in for 5. || int sum = 0;

int i;

for ( i = 0; i < 5; i++) sum =+num[i];

txtSum->Text = sum.ToString; || p 330-331 || method by value || Passing a single element or value into a programmer defined method by value as opposed to by r​eference || Passing the value in element 0 into the method ShowNum: ShowNum(num[0]); private: void ShowNum(int myNum); || p 332 ||
 * Pass a single element into a
 * Pass a single element into a method by reference || An array element can be passed by reference into a method by try parsing a value into a specific spot in the method. You must call the array element, then tell it where to go. || GetNum(num[0]);

private: void GetNum( int & myNum ) { if ( !Int32::TryParse (txtNum->Text, myNum)) MessageBox::Show("Invalid input"); } || p. 333 || double score[20] = {*numbers*}; int id[20]= {*numbers*}; int index, targetID; if (Int32::TryParse (txtID->Text, targetID)) {// txt ID contains an integer index = GradeSearch(id, targetID); if (index < SIZE) { if (!Int32::TryParse(txtNum->Text || 343-344 || methods, just like variables. The array serves as the acual parameter. Brackets are not needed. || method_name(array_name); || p. 334 || Sequential searches can be used to match one index value with another index value in a parallel array. || static const int size = (size of the array); int i; for (i = 0; i return i; || p. 341 ||
 * Parallel Arrays || a parallel array is a data structure for representing arrays of records. || //Declare Variables
 * Pass an entire array into a method || arrays can be passed as actual parameters into
 * Sequential Search || the size of the array is declared. then, for every time i=0, and i<SIZE, i++.
 * Multidemensional Arrays || Multidimensional arrays can be described as "arrays of arrays".

A multi-dimensional array of dimension n (i.e., an n-dimensional array or simply n-D array) is a collection of items which is accessed via n subscript. || const int numRows = 2; const int numCols = 3; int arr2d[numRows][numCols] = {{5,0,8},{6,7,6}}; || 348 ||