Xor_eq in C++

In this article, you will learn about the Xor_eq in C++ with their examples.

The eleven keywords in C++ are simply different ways of writing words that are normally denoted by alphanumeric characters. These keywords are also well-handled in the preprocessor. They cannot be reported as variables or guidelines; Instead, they act as operators in the #if. You can request that those keywords be translated to C++ by adding iso646.h in C++ to C. Each header is defined as an object-like macro that extends to the appropriate punctuation marks.

The following are the designated operators along with the respective punctuators:

  • and &&
  • and_eq &=
  • bitand &
  • bitor |
  • compl ~
  • not!
  • not_eq !=
  • or ||
  • or_eq |=
  • xor ^
  • xor_eq ^=

XOR(^):

  • A bitwise XOR operation is performed between the two operands using the XOR operation (^).
  • In the case where two bits do not match, the result is 1. If the two bits are equal, the result is 0.
  • For example, 1010 ^ 1100 gives 0110 (10 XOR 12 equals 6).

Assignment operators for XOR (^=):

  • By combining the left and right operands bittwise, the XOR function operator (^=) assigns the result to the left operand.
  • In this case, lhs is the left operand and rhs is the right operand. It is equivalent to lhs = lhs ^ rhs.
  • For example, a ^= b; and a = a^b; They are perfect.

Program 1:

Let us take an example to illustrate the Xor_eq function in C++.

Output:

Xor_eq in C++

Program 2:

Let us take another example to illustrate the Xor_eq function in C++.

Output:

Xor_eq in C++
Next Topic#




Latest Courses