Question 10 Assume Code Dim Nums Y Integer Assume Later Filled Array Nums Integer Values W Q28644321

Question 10:

Assume this code:

 Dim Nums(Y) As Integer

Assume later we filled the array Nums with integervalues.

Write one line of code that calculates theaverage of: the first and the last element of Nums. Display theaverage in a messagebox.

Question 11:

Assume that an array z, is declared as in:
Dim z(n) As Integer

  and that z has been filled with datain all its locations, and n is an odd number.

           <– arraycontent is integer values

012  3      n   <– index or location

Write code that uses a for loop, to calculate theaverage of every other number in z starting fromlocation 0 to location n inclusive. 

Since n is an odd number the for loop can start at thefirst location and end at the last location of z.

Think of what the step should be so we process oneelement then skip the next one and move on to the one afterthat.

After the loop show the resulting average in amessagebox. Think about the number of elements we need to divide byis half of the elements between locations 0 and n.

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *