Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. (TCO 11) An array is a list of data items that _____. (Points : 3) share the

ID: 3638053 • Letter: 1

Question

1. (TCO 11) An array is a list of data items that _____. (Points : 3)
share the same data type
are all integers
have different names
are not indexed

2. (TCO 11) An array that stores five days of closing stock prices can be declared as _____. (Points : 3)
decimal price1, price2, price3, price4, price5;
decimal [] price = new decimal[5];
decimal price[] = new decimal[5];
decimal [] price = new price[5];

3. (TCO 11) Which statement is not true about this array declaration?

int [] myArray = {1,4,3,5,6};

(Points : 3)
It declares a one-dimensional array.
Its elements are indexed 1 thru 5.
It sets the element myArray[0] to 1.
It will compile.

4. (TCO 11) Given the following declaration, what is/are the value(s) of age[1,1]?

int[,] age = { {2, 3, 6, 7},
{5, 8, 9, 4} };

(Points : 3)
2
2 5
3 8
8

5. (TCO 11) In the following code, "size" represents _____.

int[] size = {2,3,5,6,4,5};
foreach (int
val in size)
Console.Write("{0} ",val);

(Points : 3)
the number of times the loop will execute
the size of the array
the data type of each array element
the array name

6. (TCO 11) What will be the output of this code?

int[] size = { 2, 3, 5, 6, 4, 5 };
int index = Array.IndexOf(size, 3);
Console.Write("{0} ", index);

(Points : 3)
1
2
5
6

7. (TCO 11) When the name of an array, such as myArray, is passed to a method, the method receives _____. (Points : 3)
a copy of the value the first element stores
the starting address of the array
the address of each array element
a copy of the array

8. (TCO 11) To pass the entire myData array to the DisplayItems method, replace the commented line below with _____.

static void
Main()
{
int[] myData = {1,2,3,4};
//call DisplayItems
}
public static void DisplayItems(params
int[] item)
{
for (int i=0; i<item.Length; i++)
Console.Write("{0} ",item[i]);
}

(Points : 3)
DisplayItems(myData);
DisplayItems(myData[0]);
DisplayItems(ref myData);
DisplayItems(1,2,3,4);

9. (TCO 12) The size of a(n) _____ can be determined when the program is written or at runtime, whereas the size of a(n) _____ must be determined when the program is written. (Points : 3)
ArrayList, array
array, ArrayList
array, Array class
Array class, array

10. (TCO 12) In your program, myList was declared as an ArrayList. To find the number of elements in myList, write _____. (Points : 3)
int num = myList.Count;
int num = myList.Length;
int num = myList.Size;
int num = myList.Total;

11. (TCO 11) Write a C# program to store an array of these integers: 23,45,67,89,10. Use an appropriate loop to multiply all of the values in the list. Print out the result. (Points : 5)

Explanation / Answer

1) share the same data type 2) decimal [] price = new decimal[5]; 3) Its elements are indexed 1 thru 5. 4) 8 5) The array name 6) 1 7) a copy of the array 8) DisplayItems(myData); 9) ArrayList, array 10) int num = myList.Count; 11) using System; using System.Collections; namespace ArrayExamples{ class Rroduct { static void Main(string[] args) { int[] numbers = { 23,45,67,89,10 }; int product=1; foreach(int i in numbers) { product=product * i; } Console.WriteLine(product); } } }