Sum of XOR of sum of all pairs in an array | CPP program to find XOR of pair sums . ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; int xorPairSum ( int ar [ ] , int n ) { int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) sum = sum ^ ar [ i ] ; return 2 * sum ; } int main ( ) { int arr [ ] = { 1 , 2 , 3 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << xorPairSum ( arr , n ) ; return 0 ; }