You are on page 1of 1

Factorial using Sub procedure:

Module Module1
Sub Main()
Dim num As Integer
Console.WriteLine("Enter number")
num = Console.ReadLine()
factorial(num)
Console.ReadLine()
End Sub
Sub factorial(ByVal a As Integer)
Dim c, d As Integer
c = 1
d = 1
Do While (c <= a)
d = d * c
c = c + 1
Loop
Console.WriteLine("The factorial of number

is {0}", d)

End Sub
End Module

Power fuction:
Module Module1
Sub Main()
Dim c, d, e As Integer
Console.WriteLine("Enter the Base number")
c = Console.ReadLine()
Console.WriteLine("Enter the Power of above")
d = Console.ReadLine
e = power(c, d)
Console.WriteLine("the power of number is ={0}", e)
Console.ReadLine()
End Sub
Function power(ByVal a As Integer, ByVal b As Integer) As Integer
Return a ^ b
End Function
End Module

You might also like