1//write a program to print the occurrence of unique elements in an array
2#include <stdio.h>
3
4int main(int argc, char const *argv[])
5{
6
7 int arr[] = {4, 256, 2, 256, 4, 3, 3, 3, 5}, seen, count;
8 int arr_length = sizeof(arr) / sizeof(int);
9
10 for (int i = 0; i < arr_length; i++)
11 {
12
13 seen = 0;
14 count = 1;
15 for (int j = 0; j < i; j++)
16 {
17 if (arr[i] == arr[j])
18 {
19 seen = 1;
20 }
21 // printf("first loop\n");
22 }
23 if (seen == 0)
24 {
25
26 for (int k = i + 1; k < arr_length; k++)
27 {
28 if (arr[i] == arr[k])
29 {
30 count++;
31 /* code */
32 // printf("condition\n");
33 }
34 // printf("second loop\n");
35 }
36 printf("%d occurs %d times\n", arr[i], count);
37 }
38 }
39
40
41 return 0;
42}
43