Example 3: Swap Two Variables

Learn how to interchange the contents of two variables with each other.

Problem

Write a program to interchange the contents of two variables, x and y, and print their values on the console.

Get hands-on with 1400+ tech skills courses.