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
H
Harshad Futane
5
i am studying 7 th standard in semi english school of pimpri
i am founding the best free classes of programing
and i found it the name of class is *LEARNVERN*
and the class is best.
THANK YOU
A
Avinash Kumar
4
The Course is Amazing and content is also amazing bu i want the notes please provide that sir ..
I
Ishant kumar
4
best
K
Krishna dhangar
5
nice,teaching
A
Ashutosh Thakkar
5
It is as same as any college can offer or if you refer any book this as same as that. Great teaching of C language. I am really happy about this course
I
Ishant Kumar
5
i love c language
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.
Share a personalized message with your friends.