Pages

    Social Items


How to convert the VAR1 variable to VAR2 and vice versa without the need for an auxiliary variable
Converting the VAR1 variable to VAR2 and vice versa without the need for an auxiliary variable


Example: We have variable 1 and value 10 and variable 2 value 20 and we want to put the value of the first variable in the second variable and the value of the second variable in the first variable

Most programmers rely on the following method:

;int var1,var2,helper
 ;var1 = 10
;var2 = 20
;helper = var1
;var1 = var2
;var2 = helper

 The second method I will write does not need the helper variable so we can only work with var1 var2

;int var1,var2
;var1 = 10
;var2 = 20
;var1 = var1+var2
 ;var2 = var1 - var2
 ;var1 = var1 - var

Best of luck 

Converting the variables VAR1 to VAR2 without using an auxiliary


How to convert the VAR1 variable to VAR2 and vice versa without the need for an auxiliary variable
Converting the VAR1 variable to VAR2 and vice versa without the need for an auxiliary variable


Example: We have variable 1 and value 10 and variable 2 value 20 and we want to put the value of the first variable in the second variable and the value of the second variable in the first variable

Most programmers rely on the following method:

;int var1,var2,helper
 ;var1 = 10
;var2 = 20
;helper = var1
;var1 = var2
;var2 = helper

 The second method I will write does not need the helper variable so we can only work with var1 var2

;int var1,var2
;var1 = 10
;var2 = 20
;var1 = var1+var2
 ;var2 = var1 - var2
 ;var1 = var1 - var

Best of luck 

No comments:

Post a Comment