Find frequency of smallest value in an array in C++

Here we will see how to find the frequency of smallest element in an array. Suppose the array elements are [5, 3, 6, 9, 3, 7, 5, 8, 3, 12, 3, 10], here smallest element is 3, and the frequency of this element is 4. So output is 4.

To solve this we will find the smallest element of the list, then we count the occurrences of first numbers, and that will be the result.

Example

#include
using namespace std;
   int min_element(int arr[], int n){
   int min = arr[0];
   for(int i = 1; i

Output

Frequency of smallest element: 4
Updated on: 2019-11-01T07:23:53+05:30

398 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements