**(HackerRank) Write a Modular C Programming code to solve Find ODD 1, All elements in an array occurs even number of times, except one element. Find the element which occurs odd number of times.**

All elements in an array occur an even number of times, except one element. Find the element which occurs odd number of times.

**Input Format**

First-line contains ‘N’, number of array elements followed by ‘N’ elements separated by a space in the next line

**Constraints**

N>0 and N<=10^4

-10^5<=a[i]<=10^5

**Output Format**

Output the element occurring odd number of times.

**Sample Input 0**

```
-1
```

**Sample Output 0**

```
Invalid
```

**Sample Input 1**

```
9
1 2 3 1 3 4 2 2 4
```

**Sample Output 1**

```
2
```

**Explanation 1**

`We clearly see that all elements occurs even number of times except 2`

**Refer :** C Programming HackerRank all solutions for Loops | Arrays | strings

**CODE:**

#include<stdio.h> #include<stdlib.h> #include<string.h> #include<math.h> int main() { int n; scanf("%d",&n); if(n>0) { int array[n],i,j,count; for(i=0;i<n;i++) { scanf("%d",&array[i]); } for(i=0;i<n;i++) { count=0; for(j=0;j<n;j++) { if(array[i]==array[j]) count++; } if(count%2!=0) { printf("%d",array[i]); break; } } } else{ printf("Invalid"); } return 0; }

**OUTPUT**

Congratulations, you passed the sample test case. Click the Submit Code button to run your code against all the test cases. Input (stdin) -1 Your Output (stdout) Invalid Expected Output Invalid

**Please find some more codes of Loops, Condition Statements, 1D Arrays, 2D Arrays, Strings, Pointers, Data Structures, Files, Linked lists, MISC, Solved model question papers & Hacker Rank all solutions on the below page:**

Top 100+ C Programming codes – KLE Technological University