Code questions

User Generated

Uhffnva98

Programming

Description

i have some questions for programm

Unformatted Attachment Preview

1. Write a method which receives a 1-dimensional array named a[and returns the index of the first nonzero element in the array. If there are no nonzero elements in the array your method should return -1. You can use the sample main program below to test your method. Your method should work for any integer 1-D array - not just the one in the main program below. static void Main(string[] args) {int [] a = {0, 0, 0, 1, 2, 3, 4, 5}; Console.WriteLine(MyMethod(a)); } 3. If an array is defined by the statement int [] a = new int[30]; , answer the following questions: A) How many integers can be stored in the array? B) Write a statement to store the number 54 in the last element of the array. C) If the user write the statement below, what are the possible results? Explain. a[34] = 22; D) Write a short sequence of statements to exchange the values in element A[12] with the value in a[11]. 4. By default, arrays are passed to methods by reference. Why does this save memory space? 2 Walte an equivalent or loop for the while loop shown below. int while (3) Ceneele.WriteLine(14) 9. Write an equivalent while loop for the for loop shown below. for(i=12181-B) doneele Weiteline (11) 1 Same= - Cetlen 5. Mark each statement A to D below as true or false. The statement apply after the following code fragment runs. int [] x = {9, 8, 7, 6}; //line 1 int [] y = {12, 15, 4, 3}; //line 2 X[2] = 4; //line 3 y[@] = x[3]; //line 4 x[y[3]] = 12; //line 5 A) line 5 is illegal B) x[1] = 8 C) y[3] =4 D) y[0] =9 logy 6. The following code creates a 2D array and calls a method FillRandom to fill the array with- random numbers in the range 3
Purchase answer to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Explanation & Answer

The solution is ready. I'll post all with the exception of the questions in the last photo, in which some of the details were clipped out by the camera. you can resend it so that i may be able to provide you with the complete solution.Thanks in advance and I have loved working with you,

Solutions to the given questions...


Anonymous
Just the thing I needed, saved me a lot of time.

Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4

Related Tags