Pages

Blogger Themes

Showing posts with label Swapping two numbers without a temporary variable. Show all posts
Showing posts with label Swapping two numbers without a temporary variable. Show all posts

Swapping any two numbers without a temporary variable


'‘**************************************************************************
‘Swapping any two numbers without a temporary variable
'‘**************************************************************************

Dim Num1
Dim Num2

Num1=InputBox ("Enter Num1")
Num2=InputBox ("Enter Num2")
Print (" Before Swapping Num1 Value:" & Num1)
Print (" Before Swapping Num2 Value:" & Num2)

Num1=Num1-Num2
Num2=Num1+Num2
Num1=Num2-Num1
Print (" After Swapping Num1 Value:" & Num1)
Print (" After Swapping Num2 Value:" & Num2)

Results window


Showing posts with label Swapping two numbers without a temporary variable. Show all posts
Showing posts with label Swapping two numbers without a temporary variable. Show all posts

Monday

Swapping any two numbers without a temporary variable


'‘**************************************************************************
‘Swapping any two numbers without a temporary variable
'‘**************************************************************************

Dim Num1
Dim Num2

Num1=InputBox ("Enter Num1")
Num2=InputBox ("Enter Num2")
Print (" Before Swapping Num1 Value:" & Num1)
Print (" Before Swapping Num2 Value:" & Num2)

Num1=Num1-Num2
Num2=Num1+Num2
Num1=Num2-Num1
Print (" After Swapping Num1 Value:" & Num1)
Print (" After Swapping Num2 Value:" & Num2)

Results window