Challenge: Swap the Values Without Using an Extra Variable
Exchange the values of two variables without using an extra variable. We will still write pseudocode and draw a flowchart of the solution.
We'll cover the following
Problem statement
You have two variables n1 and n2 containing two numbers, and you want to swap the values that they hold, without using a third temporary variable.
Input
You take the numbers n1 and n2 as the input.
Output
The output is two variables with their values swapped.
Get hands-on with 1200+ tech skills courses.