Relative Content

Tag Archive for cnumbersswap

My number swap program doesn’t seem to be working as intended

So, I am currently learning C and while trying to replicate the code in the manual I was given, I noticed the output is different from what is demonstrated in the manual.
The program is supposed to swap two numbers repeatedly and each time to increment a variable in order to indicate how many swaps have ocurred. However, when I run it, whether it be on visual studio or on online compilers, the counter increments correctly, but the swaps seem to be one swap behind.
Here is the code: