What is the minimum number of temparory variables needed to swap two numbers
Answers
Answered by
0
Question
What is the minimum number of temparory variables needed to swap two numbers
ANSWER
__________________________________________
The minimum number of temporary variables required to swap two variables is ONE ( 1 )
because if you try directly swapping the two then the first value will be distorted and you cant keep it into the other variable but on using one temporary variable value of second variable can be stored in it and then value of first value stored in second. After that vaalue of third variable ( storing value of second ) can be used.
___________________________________________
HOPE IT HELPS :):)
Similar questions