COMP SCI 302 Chapter Notes - Chapter 4-5: Eval
Document Summary
An array is a special variable having one name, but storing a list of data items, with each item directly accessible. Some languages use a construct similar to an array called a vector. Each item in an array is known as an element. Array indices: the last index is at n - 1, where n is the number of elements, because the first element has index 0. Defining an array i nt[] my ar r ay = ne w i nt [ 5] ; . // 5 means there will be 5 elements with indexes 0,1,2,3,4 or i nt [] my ar r ay = { 1, 1, 1}; Common for loop structure for iterating through an array. // it er ati ng t hr ough my ar r ay f or (i = 0; i < nu mel e me nt s; ++i ) { // loop body accessi ng my ar r ay[i]