How to use swap function in C programming

In C, a function can be passed argument by value to function, but it cannot change the value in the variable. It’s a concept of “Pass by Values”. It’s only copies of the actual parameter’s value in program memory.

The below swap example demonstrates how the swap routine only change the copies of the variable x & y, but not the original variables.

In this case, pointer’s argument can come into play.

Pointer’s argument can gain access or alter the object of the function. In this swap case, we can pass pointers to the values that can be changed later.

In other words, the location of the variable changes, so the original variable can change its value.

Have a better ideas? PM me now!

--

--

Charmarine_DataAnalytics&DataWizardForMarketing

The Marketing Data-Driven blog ties together the what, the why and the how behind tried and true digital marketing techniques