This is the program I need to re-write and I dont understand.

Sub Main()

    Dim array(24) As Double, i As Long
    array(0) = 1

    For i = 1 To 24
        array(i) = 2 * array(i - 1)
    Next i

    Call DisplayArray(array)

End Sub

Sub DisplayArray(ByVal array() As Double)

    Dim i As Long, n As Long
    n = array.GetLength(0)

    For i = 0 To n - 1
        Console.WriteLine(array(i))
    Next i

End Sub

I need to Rewrite the program so that it is a function
That takes in as paremeters an array and constant k.
The Program should return an array where array(i) is equal to k

Recommended Answers

All 4 Replies

Try right click Refactor!

Your spec is incomplete.

  1. write a function
  2. with two parameters, an array and constant k
  3. should return an array where array(i) is equal to k

You didn't specify what i is. It isn't a parameter, and if it is a global then the design is bad.

By the way, please use the CODE tool for inserting code so that it displays correctly. I fixed it for you.

Sorry array(i) shoudl equal Ki and k=3

So

  1. write a function
  2. with two parameters, an array and constant k
  3. should return an array where Ki is equal to k

That makes even less sense.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.