Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
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
#includeusing namespace std; int min_element(int arr[], int n){ int min = arr[0]; for(int i = 1; i Output
Frequency of smallest element: 4
Advertisements
