Complete the code to initialize the variable that will hold the XOR result.
int unique = [1];We start with 0 because XOR with 0 leaves the number unchanged.
Complete the for loop to iterate over the array elements.
for (int i = 0; i [1] n; i++) { unique ^= arr[i]; }
The loop runs from 0 to n-1, so the condition is i < n.
Fix the error in the XOR operation inside the loop.
unique [1] arr[i];XOR assignment operator ^= is used to combine bits.
Fill both blanks to complete the function signature and return statement.
int findUnique(int [1][], int [2]) { int unique = 0; for (int i = 0; i < n; i++) { unique ^= arr[i]; } return unique; }
The function takes an array named arr and its size n.
Fill all three blanks to complete the main function that calls findUnique and prints the result.
#include <stdio.h> int findUnique(int arr[], int n); int main() { int arr[] = {2, 3, 5, 4, 5, 3, 4}; int n = sizeof(arr) / sizeof([1]); int unique = findUnique(arr, [2]); printf("Unique element is %[3]d\n", unique); return 0; }
sizeof(arr[0]) gives size of one element, n is passed as array size, and %d is format specifier for int.
