Tuesday, May 5, 2020

7 and Array free essay sample

Primenumber1. An array is a list of data items that _____. are of different data types are all integers have different names are indexed | 2. An array that stores five days of closing stock prices can be declared as _____. decimal price1, price2, price3, price4, price5; decimal [] price = new decimal[5]; decimal price[] = new decimal[5]; decimal [] price = new price[5];| 3. Which statement is true about this array declaration? int [] myArray = {1,4,3,5,6}; It declares a 5 dimensional array. The size of the array is five. It sets the element myArray[1] to 1. It wont compile due to a syntax error. | 4. Given the following declaration, what is/are the value(s) of height[1,1]? double[,] height = { {2. 1, 3. 2, 6. 5, 7. 2}, {5. 4, 6. 7, 3. 5, 3. 6} }; 2. 1 2. 1 5. 4 3. 2 6. 7 6. 7| 5. In the following code, the foreach statement _____. int[] size = {2,3,5,6,4,5}; foreach (int val in size) Console. Write({0} ,val); can read and write data to each array element iterates through each element of the array returns the memory address of each array element prints the index of each array element| . We will write a custom essay sample on 7 and Array or any similar topic specifically for you Do Not WasteYour Time HIRE WRITER Only 13.90 / page What will be the output of this code? int[] size = {2,3,5,6,4,5}; Array. Sort(size); foreach (int val in size) Console. Write({0} , val); 2 3 5 6 4 5 5 4 6 5 3 2 6 5 5 4 3 2 2 3 4 5 5 6 | 7. When a single array element, such as myArray[2], is passed to a method, the method receives _____. the starting address of the array a copy of the value the element stores the address of the element a copy of the array| 8. To pass the entire myData array to the DisplayItems method, replace the commented line below with _____. tatic void Main() { int[] myData = {1,2,3,4}; //call DisplayItems } public static void DisplayItems(params int[] item) { for (int i=0; ilt;item. Length; i++) Console. Write({0} ,item[i]); } DisplayItems(myData); DisplayItems(myData[0]); DisplayItems(ref myData); DisplayItems(1,2,3,4);| 9. The size of a(n) _____ must be determined when the program is written, whereas elements of a(n) _____ can be added or deleted at runtime. ArrayList, array array, ArrayList array, array ArrayList, ArrayList | 0. In your program, myList was declared as an ArrayList. To append the number 7 to the end of myList, write _____. myList. Add(7); myList. Append(7); myList. Insert(7); myList. Set(7);| 11. Write a C# program to store an array of these integers: 11,22,33,44,55. Use an appropriate loop to add all of the values in the list. Print out the sum. | | string [] value = new string [5]; value[0] = 11 value[1] = 22 value[2] = 33 value[3] = 44 value[4] = 55 foreach(sting s in value) Console. WriteLine(s);

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.