0

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

Edited by Reverend Jim: reformatted code

3
Contributors
4
Replies
23
Views
3 Years
Discussion Span
Last Post by Reverend Jim
0

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.

Edited by Reverend Jim

0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.