top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration

Facebook Login
Site Registration

Find the number occurring odd number of times in an array?

+1 vote
93 views

For eg. 1,4,6,7,3,1,4,7,3,1,6 (given array)

posted Dec 9, 2014 by Vrije Mani Upadhyay

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote
int OddOccur(int arr[], int ar_size)
{
     int i,out = 0;

     for (i=0; i < ar_size; i++)
     {
                out = out ^ arr[i];
     }

     return out;
}

main()
{
     int arr[] = { 1,4,6,7,3,1,4,7,3,1,6 };
     int n = sizeof(arr)/sizeof(arr[0]);
     printf("%d", OddOccur(arr, n));
}
answer Dec 9, 2014 by Sridharan P
Similar Questions
+3 votes

In an "N" element integer sorted array, a particular elements is repeating "(N/2)+1" times. How much time it take to find the repeating element.

+1 vote

Given an array of 1s and 0s which has all 1s first followed by all 0s. Find the number of 0s. Count the number of zeroes in the given array.

Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...