Append two elements to make the array satisfy the given condition | C ++ implementation of the approach ; Function to find the required numbers ; Find the sum and xor ; Print the required elements ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; void findNums ( int arr [ ] , int n ) { int S = 0 , X = 0 ; for ( int i = 0 ; i < n ; i ++ ) { S += arr [ i ] ; X ^= arr [ i ] ; } cout << X << " ▁ " << ( X + S ) ; } int main ( ) { int arr [ ] = { 1 , 7 } ; int n = sizeof ( arr ) / sizeof ( int ) ; findNums ( arr , n ) ; return 0 ; }