Exercise 3: Finding Index of the Smallest Value
Find the index of the smallest value in an array.
We'll cover the following
Problem statement
The code widget below declares two index_of_smallest
functions—one for finding the index of the smallest value in an int
array, and the other for a double
array.
Define a template class type function index_of_smallest
that generalizes the function such that it finds the minimum value index for both int
and double
type array input values. The function for finding the index of the smallest value in an array takes the following two values:
Array of values
Size of array
Note: Remove both the
int
anddouble
typeindex_of_smallest
functions and then write the code for the template class typeindex_of_smallest
function there.
Sample input
Create a free account to access the full course.
Continue your learning journey with a 14-day free trial.
By signing up, you agree to Educative's Terms of Service and Privacy Policy