# Element appearing once binary search

QUESTION

Given an sorted array A[i] of N positive integers having all the numbers occuring exactly twice, except for one number which will occur only once. Find the number occuring only once.\n\nInput\nThe first line of input contains an integer T denoting the number of test cases. Then T test cases\nfollow. The first line of each test case contains a positive integer N, denoting the size of the array.\nThe second line of each test case contains a N positive integers, denoting the elements of the\narray.\n\n\nOutput\nPrint out the singly occuring number.\n\n\nConstraints\n1 <= T <= 100\n0 < N <= 100\n0 <= A[i] <= 100

``````#include <stdio.h>
int main()
{
int i;
scanf("%d",&i);
for(;i>0;i--)
{
int j,n,a;
scanf("%d",&n);
for(j=0;j<n;j++)
scanf("%d",&a[j]);
for(j=0;j<n;j=j+2)
if(a[j]!=a[j+1])
break;
printf("%d\n",a[j]);
}
return 0;
}`````` #### Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker. 