Challenge: Fix the Code

Here is a coding challenge based on the concepts of the function parameters.

The program given below is trying to swap the values of two arguments but fails to do s0.

Problem statement #

Fix the swap() function so that the values of a and b are swapped.

Sample input #

a = 1;
b = 2;

Sample output #

a = 2;
b = 1;

Challenge #

This problem is designed for you to practice, so try to solve it on your own first. If you get stuck, you can always refer to the explanation and solution provided in the next lesson. Good luck!

Get hands-on with 1200+ tech skills courses.