Using an assignment operator to calculate a power of 2


Module Tester

Sub Main()
Dim exponent As Integer ‘ power input by user
Dim result As Integer = 2 ‘ number to raise to a power

exponent = 12

result ^= exponent ‘ same as result = result ^ exponent
Console.WriteLine(“result = exponent: {0}”, result)

result = 2 ‘ reset result to 2
result = result ^ exponent
Console.WriteLine(“result = result  exponent: {0}”, result)

End Sub

End Module

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s