Code questions

i have some questions for programm

Save Time On Research and Writing
Hire a Pro to Write You a 100% Plagiarism-Free Paper.
Get My Paper

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

Still stressed from student homework?
Get quality assistance from academic writers!

Order your essay today and save 25% with the discount code LAVENDER