To swap two variables, use the bitwise XOR operator. When two integers x and y are XORed, the result is a number with all bits set to 1 wherever the bits of x and y differ. For instance, the XOR of 10 (in Binary 1010) and 5 (in Binary 0101) is 1111, while the XOR of 7 (0111) and 5 (0101) is 1111. (0010).
This is a question that most of us have asked at some point in our lives. However, it is not easy to answer because there are so many possibilities. C language uses the two-operand instruction for swapping the two numbers in the expression on the left and right side of the equals sign. This is called a swap instruction. When C language executes an assignment statement, it first stores an old value in memory and then assigns a new value to the old memory location. This process is called de-referencing.
If you have a=1 and b=2, you are swapping. If you do a=2 and b=1 in any way, this number will be swapped. You can swap numbers with or without the use of variables!
Swapping two numbers in C can have consequences on the functionality of the program. For example, if you swap two numbers, it can cause an overflow error or undefined behavior.
Learner's Ratings
4.4
Overall Rating
69%
18%
5%
4%
4%
Reviews
P
PATAN MASTHAN
5
sir need c notes it is very useful us to read after listening class so i request u do please provide notes......................masthimasthan786@gmail.com this is my mail
L
Lalita
5
this courses are very helpful. thank you so much.
B
Biwek Gorai
5
I like this course , thank you for your free courses, your free course many people for helpful.
S
SHAYAQ SHAFI
5
sir please provide pdf
Y
Yash Lohiya
5
I am really thanks to learnvern because they give best lectures without any cost sir please. I am really requesting please give us pdf
S
Sonu Kumar
5
teaching is really very awesome.
If assignment would be in the pdf along with lecture. then it would be more benificial.
A
ashish patil
5
Teaching is very best everything is understanding thank you so much 🙏
Share a personalized message with your friends.