Consider the following event procedure that calls a Function procedure named Cube, which
returns the cube of a number.
Private Sub btnDisplay_Click(...) Handles btnDisplay.Click
Dim num, result As Double
num = CDbl(InputBox("Enter a number to cube:"))
result = Cube(num)
txtBox.Text = "The cube of " & num & " is " & result & "."
End Sub
Which of the following is a correct Function definition for Cube?
1. Function Cube(var As Double) As Double
Return var ^ 3
End Function
2. Function Cube(num As Double) As Double
Return num ^ 3
End Function
(A) 1 only
(B) 2 only
(C) Both 1 and 2
(D) Neither 1 nor 2
Answer: C