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.

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.