CS 204 - Computer Programming II
Assignment 01 - Arrays Name: _______________________________
Due Thrs 01/28/2010
The ____________________ indicates the number of elements, or values, an array can hold.
The size declarator must be a(n) ____________________ with a value greater than ____________________.
Each element of an array is accessed and indexed by a number known as a(n) ____________________.
Subscript numbering in C++ always starts at ____________________.
The number inside the brackets of an array definition is the ____________________, but the number inside an array’s brackets in an assignment statement, or any other statement that works with the contents of the array, is the ____________________.
C++ has no array ____________________ checking, which means you can inadvertently store data past the end of an array.
Starting values for the elements of an array may be specified with a(n) ____________________ list.
If a numeric array is partially initialized, the uninitialized elements will be net to ____________________.
If the size declarator of an array definition is omitted, C++ counts the number of items in the ____________________ to determine how large the array should be.
Look at the following array definition.
int values[12];
How many elements can the array hold?
What is the subscript of the first element in the array?
What is the subscript of the last element in the array?
If an int uses four bytes of memory, how much memory does the array use?
Look at the following array definition.
int numbers[5] = { 1, 2, 3 };
What value is stored in numbers[2]?
What value is stored in numbers[4]?
Given the following array definition:
int values[5] = { 4, 7, 6, 8, 2 };
What does the following statement display?
cout << “ “ << (values[2] + values[3]) << “ “ << values[values[4]] << endl;
Answer the following questions regarding an array called fractions.
Define a constant variable ARRAY_SIZE initialized to 10.
Declare an array with ARRAY_SIZE elements of type float.
Initialize the array elements to 0.
Assign the value 1.667 to array element 9.
Assign the value 3.333 to array element 10.
Print array elements 6 and 9 with two digits of precision to the right of the decimal point and show the output that is actually displayed on the screen.
1504 WIS JI‑CRIMINAL 1504 1504 COMPUTER CRIME — §
16 MEMORY COMPUTER SCIENCE 240 LABORATORY 7 IN LAB
216 MALVERN HOT SPRING COUNTY LIBRARY COMPUTERINTERNET USE
Tags: assignment 01, an assignment, assignment, programming, computer