Find the value of N XOR 'ed to itself K times | C ++ implementation of the approach ; Function to return n ^ n ^ ... k times ; If k is odd the answer is the number itself ; Else the answer is 0 ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; int xorK ( int n , int k ) { if ( k % 2 == 1 ) return n ; return 0 ; } int main ( ) { int n = 123 , k = 3 ; cout << xorK ( n , k ) ; return 0 ; }