1 1 Berlin Asked: January 13, 20222022-01-13T15:54:30+05:30 2022-01-13T15:54:30+05:30In: Programming Language C program to count frequency of each element in an array 1 1 C program to count frequency of each element in an array c languagecount frequency Share Facebook 1 Answer Voted Oldest Recent I'M ADMIN 2022-01-13T15:58:53+05:30Added an answer on January 13, 2022 at 3:58 pm #include <stdio.h> int main() { int arr[100], freq[100]; int size, i, j, count; printf("Enter size of array: "); scanf("%d", &size); printf("Enter elements in array: "); for(i=0; i<size; i++) { scanf("%d", &arr[i]); freq[i] = -1; } for(i=0; i<size; i++) { count = 1; for(j=i+1; j<size; j++) { if(arr[i]==arr[j]) { count++; freq[j] = 0; } } if(freq[i] != 0) { freq[i] = count; } } printf("\nFrequency of all elements of array : \n"); for(i=0; i<size; i++) { if(freq[i] != 0) { printf("%d occurs %d times\n", arr[i], freq[i]); } } return 0; } OUTPUT: Copy Leave an answerCancel replyYou must login to add an answer. Username or email* Password* Remember Me! Forgot Password?
1 Answer