Preview

7 and Array

Good Essays
Open Document
Open Document
500 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
7 and Array
1. 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 won't 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 | 6. 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 _____.

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]);
}

DisplayItems(myData);
DisplayItems(myData[0]);
DisplayItems(ref myData);
DisplayItems(1,2,3,4); | 9. The

You May Also Find These Documents Helpful

  • Satisfactory Essays

    6. What is the difference between passing an argument by value and passing it by reference?…

    • 765 Words
    • 5 Pages
    Satisfactory Essays
  • Good Essays

    Nt1420 Unit 6

    • 1145 Words
    • 5 Pages

    INSTRUCTIONS: 1. THERE ARE SIX (6) QUESTIONS IN THIS PAPER. 2. ANSWER FIVE (5) QUESTIONS ONLY. Question 1 Arrays are used when storing a large number of values. You are required to create an array named a and answer the following questions regarding array manipulation. a. Write a method fillRandom(int[] a, int min, int max), fill the array a with a random integer value. (Note: Math.random() returns a double in the range of 0.0 and 1.0, therefore it is cast to an integer number, between the minimum and maximum value). [6 marks] b. Write the Bubble sort method to sort array a into descending order. [10 marks] c. In the quicksort, an algorithm an element is chosen from the unsorted list. This element is called the…

    • 1145 Words
    • 5 Pages
    Good Essays
  • Good Essays

    Exercise 1: Review of array-based lists Create a project using the classes in the DocSharing area labeled “User-defined array list." Compile it, run it, and review the code that is given carefully. This code tests the ArrayList class provided in the lecture.…

    • 714 Words
    • 3 Pages
    Good Essays
  • Good Essays

    ECET 370 Week 5 Lab 5

    • 650 Words
    • 3 Pages

    Exercise 1: Review of the Lecture Content Create a project using the ArrayList class and the Main class provided in DocSharing. The ArrayList class contains implementations of the first three search methods explained in this week's lecture: sequential, sorted, and binary search. The Main class uses these three methods. These programs test the code discussed in the lecture. Compile the project, run it, and review the code that is given carefully.…

    • 650 Words
    • 3 Pages
    Good Essays
  • Good Essays

    Nt1310 Unit 3 Quiz

    • 6337 Words
    • 26 Pages

    /*question number 3*/ Code: void *ptr; myStruct myArray[10]; ptr = myArray; Which of the following is the correct…

    • 6337 Words
    • 26 Pages
    Good Essays
  • Powerful Essays

    Nt1330 Unit 1 Research Paper

    • 4285 Words
    • 18 Pages

    Each character requires one byte as it is usually stored as an ASCII character. Notice that a digit such as 8 could be held as either a character, an integer or even a real. If any calculations are going to take place on the value then it should be held as either an integer or a real. If the calculation will never result in it being extremely large or gaining decimal places then an integer should be used.…

    • 4285 Words
    • 18 Pages
    Powerful Essays
  • Satisfactory Essays

    NT 1230 CLIENT

    • 374 Words
    • 2 Pages

    d. RAID 6: a combination of RAID levels that utilize multiple RAID 5 sets striped in a single array. A single hard drive failure can occur in each of the RAID 5 sides without any loss of data on the entire array. If more than one disk in any of the RAID 5 arrays all the data in the array is lost.…

    • 374 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Each of the following statements may (or may not) describe one of these technical terms. For each statement, indicate the accounting term described, or answer “None” if the statement does not correctly describe any of the terms.…

    • 1713 Words
    • 9 Pages
    Satisfactory Essays
  • Good Essays

    9. A method that stores a value in a class’s field or in some other way changes the value of a field is known as a…

    • 1518 Words
    • 7 Pages
    Good Essays
  • Good Essays

    Chapter 8 Quiz

    • 469 Words
    • 2 Pages

    Chapter 8 Quiz 1. Processing a large number of items in a(n) ________ is usually easier than processing a large number of items stored in separate variables. (Points : 6)…

    • 469 Words
    • 2 Pages
    Good Essays
  • Good Essays

    Questions on Accounting

    • 589 Words
    • 3 Pages

    7. Indicate whether each of the following items is a real or nominal account and whether it appears in the balance sheet or the income statement…

    • 589 Words
    • 3 Pages
    Good Essays
  • Better Essays

    6) When you pass by value you pass a copy. When you pass by reference, you can modify the contents.…

    • 1580 Words
    • 11 Pages
    Better Essays
  • Satisfactory Essays

    Ac555 Midterm Exam

    • 644 Words
    • 3 Pages

    | (TCO F) Which of the following statements is true of a public company's financial statements?…

    • 644 Words
    • 3 Pages
    Satisfactory Essays
  • Good Essays

    it320 assignment 1-3

    • 1779 Words
    • 8 Pages

    5. This chapter describes the concepts behind how a CPU reads the contents from RAM. Which of the following is true about the process of read data, as described in the chapter? (A. the CPU tells the RAM which address holds the data that the CPU wants to read.)…

    • 1779 Words
    • 8 Pages
    Good Essays
  • Satisfactory Essays

    It 218 Week 4 Checkpoint

    • 290 Words
    • 2 Pages

    An array is a variable that holds more than more than one value, and an array can be combined with multiple variables for a more complex structure. An array is declared much similar with any other variable. The only difference is the number of elements is shown in brackets. An example of an array will be look much like these three: calories [ min ], 30 [ 7 ], and feet [ 12 ]. Each one of these arrays can be used as long as it is appropriate for the program.…

    • 290 Words
    • 2 Pages
    Satisfactory Essays

Related Topics