Skip to content

Instantly share code, notes, and snippets.

@ajayguru2
Created January 24, 2018 06:36
Show Gist options
  • Save ajayguru2/b41a0474df777bc35fe5eddeb449bef0 to your computer and use it in GitHub Desktop.
Save ajayguru2/b41a0474df777bc35fe5eddeb449bef0 to your computer and use it in GitHub Desktop.
Calculating XOR of array
#include <iostream>
int main(){
std::cout<<"Enter the Array"<<std::endl;
int array[5];
int result;
result = 0;
for (int i = 0; i < 5; ++i) {
std::cin>>array[i];
}
for (int j = 0; j < 5; ++j) {
for (int k = 0; k < 5; ++k) {
if (array[j] != array[k]){
result = result + (array[k] ^ array[j]);
}
}
}
std::cout << result;
return 0;}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment