Lab 9

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

In a fixed-length array the size of the array is known when the program is written.

False (when its run)

The name of an array is a primary expression whose value is the address of the first element in the array

True ( this is the reason that the index begins at zero; every element following the first element's (index 0) location increments by one due to this offset memory address (location) is not equivalent to the value of a[0])

An array must be declared and defined before being used. Declaration and definition tell the compiler the name of the array, the type of each element, and the size of the array.

True

An array reference is a postfix expression with the opening and closing brackets as operators.

True

Array declarations will determine the type, name, and size of the array.

True

Arrays can be passed in two ways; by individual elements or the whole array.

True

Arrays must be declared and defined before they can be used.

True

C does not do boundary checking on the elements of an array

True

If a one-dimensional array is completely initialized when it is declared, it is not necessary to specify the size, but it is recommended.

True

Initialization of all elements of a fixed length array can be done at the time of the declaration and definition

True

Searching is the process of finding the location of a target among a list of objects

True

The insertion sort divides the array into sorted and unsorted sublists. In each pass, the algorithm inserts the first element from the unsorted list into the appropriate place in the sorted sublist.

True

The name of an array is a reference to the address of where it begins inside the memory of the computer.

True

The sequential search starts at the beginning of the array and searches until it finds the data or hits the end of the list. The data may be ordered or unordered

True

Three things are needed to declare and define an array: name, type, and size.

True

To exchange the value of two elements in an array, you need a temporary variable.

True

To initialize all elements in an array to zero, all you need to do is initialize the first element to zero

True

To pass a variable-size array to a function, you need either to include the variable defining the array size or use an asterisk.

True

To pass a whole variable-length array to a function, you need to also pass its size.

True

To pass the whole array to a function, you only use the name of the array as an actual parameter.

True

Variables and loops are commonly used together to generate index values to access the elements of an array.

True

We can fill the elements of an array by using a loop to read the values from the keyboard or a file.

True

We can pass an individual element of an array to a function either by value or by address

True

We can pass either a single element, a row, or the whole two-dimensional array to a function

True

We can read or write the values of an array using a loop

True

To pass the whole array to a function you need to use the name of the array followed by empty square braces [ ] in the function call statement

False (no braces when it comes to the function call; just the name of the array)

When passing a whole array to the function the total size of the array is necessary in the definition of the called function

False (the array will be passed by address, thus size isn't supposed to be included, as the values are being modified are restored in the main function; this isn't necessary to have passed an array by address)

All elements of one array can be assigned to another through the use of the assignment operator and the name of each array (example: x = y)

False (the array's name only reserves so much memory/elements in an array; need to copy an array in order to assign values in this way through the strcpy function (ie if strcpy(str1, str2), str2 information will be copied into str1 to override those values); this will produce a compiler error)

All arrays sent to a given user-defined function must be of the same defined size

False (there is no reason why the size should matter in the grand scheme of the program)

For a value to be potentially used as an index it must be an integral value or an expression that evaluates to such

True

In an array declared as array [n], the index goes from 0 (not 1) to n-1

True

Indexed references to individual elements of an array are simply calculated addresses where the index value is added to the address represented by the name of the array

True

Individual elements of an array can be passed by address through the use of the address operator.

True

It is a compile error to omit the array size in the parameter declaration for any array dimension other than the first.

True

It is a course standard to make use of a symbolic/defined constant to represent the size of a statically declared array.

True

It is only the starting point of the array in memory that is represented by the name of an array and not the ending point

True

The bubble sort divides the array into sorted and unsorted sublists. In each pass, the algorithm bubbles the smallest element from the unsorted list into the sorted sublist.

True

The called function cannot identify whether the value it receives comes from an array, an individual variable, or an expression that evaluates to the expected type

True

The elements of an array are not initialized automatically. You must initialize them if you want them to start with known values.

True

The index value represents an offset from the beginning of the array to the element being referenced

True

The reason that the C language does not pass whole arrays by value is the extra stress it would put on the memory of the computer to make a copy of an array

True

The selection sort divides the array into sorted and unsorted sublists. In each pass, the algorithm chooses the smallest element from the unsorted sublist and swaps it with the element at the beginning of the unsorted sublist.

True

We can access the individual elements of an array using the array name and the index

True

We can also pass the whole array to a function. In this case, only the address of the array will be passed. When this happens, the function has access to all elements in the array

True

We use indexes in C to show the position of the elements in an array

True

When accessing an array element the C language does not check whether the index is within the boundary of an array

True

When an array is partially initialized, the rest of the elements are set to zero.

True

While the default technique of passing array elements is by value it is possible to pass elements by address using the & operator (and the * operator in the function being called)

True

You cannot copy all elements of one array into another with an assignment statement. You need to use a loop.

True

Passing the array name to a function allows changes in the called function to be available back in the calling function after it terminates

True (it passes arrays by address, thus modifying its values)

Elements of an array, themselves individual values of a given data type, are passed by value from calling to called function

True

The conversion code to use for input or output of an array element depends on the data type of the array

True

printf statement for an array should be: scanf("%f", &costAry[0]);

True

An array can be sorted using a sorting algorithm

True

When passing a whole array to the function the total size of the array is necessary in the function call.

False

Declaration and definition of an array will include a default initialization of all elements

False ( the initialization of the array will include all the elements in the array only see: int x[SIZE] = {1, 2, 3, 4};)

A multidimensional array is an extension of a two-dimensional array to three, four, or more dimensions

True

The address operator is not necessary in a scanf to accept input for an individual array element when using the indexing technique

False (Explanation: passing by address needs address operators, whereas the name of an array serves as the memory location for the full array)

If the number of values provided for initialization of an array is fewer than the size of the array then the remaining elements have no known value.

False (Explanation: the values are equal to zero; if the array is not initialized, then their values will be unknown)

Arrays in the C programming language use a one-based index

False (arrays begin at a zero-based index because the index represents an offset from the memory location)

If more than one element of an array is passed to a function in a single function call then those elements are passed by address

False (individual elements of an array can be passed by value unless you are passing the entire array)

Using the name of an array in the data list of a single printf function will result in the output of all elements of the array

False (it will print the array's memory location (ie 300))

A one-dimensional array is a fixed sequence of elements of the same type

True

A two-dimensional array is a representation of a table with rows and columns

True

A binary search is a much faster searching algorithm. In the binary search, each test removes half of the list from further analysis. The data must be ordered

True

A frequency array is an array whose elements show the number of occurrences of data values in another array

True

A histogram is a pictorial representation of a frequency array

True


Set pelajaran terkait

HNF 150 FOOD INSECURITY + HUNGER & SUSTAINABLE FOOD SYSTEMS

View Set

Exam 3 study guide Strength and Conditioning

View Set