Cookie 1

Swapping Values with Only Two Variables

Goal:

Solve this problem and get a small prize.

Rules:

No outside help (book, friend, Internet, etc).  This is just you and your brain.

Problem:

            In Lesson 2, we  mention how to swap data values using 3 variables and ask you to understand why

                  Y=X

                  X=Y  

            doesn't work. 

 

           But can you show how to swap data values between X and Y using only 2 variables?? 

           Describe your algorithm and give and provide an example of the values of the variables after each step.

Turn-in:

          Upload to the course web site before Lesson 3 into the cookie jar (a.k.a. the "DropBox") or email it to me if the link is broken.