Function power local variables Learn programming Visual Basic (




Function power local variables 14


Create a function named "Power" to calculate the result of raising an integer number to another (positive integer) number. It must return another integer number. For example. Power(2,3) should return 8.

Note: You MUST use a repetitive structure, such as "for " or "while", you cannot use Math.Pow.


Imports System
Public Class exercise107
    Public Shared Sub Main()
        Dim number As Integer
        Dim exponent As Integer
        Console.Write("Base: ")
        number = Convert.ToInt32(Console.ReadLine())
        Console.Write("Exponent: ")
        exponent = Convert.ToInt32(Console.ReadLine())
        Console.WriteLine("{0}^{1}={2}", number, exponent, Power(number, exponent))
    End Sub

    Public Shared Function Power(ByVal number As Integer, ByVal exponent As Integer) As Integer
        Dim result As Integer = 1
    End Function
End Class