Define a C++ function Min that takes an array of floating point numbers X and number of data N (N is integer) and determines the minimum of all the values and returns the minimum value. Now complete the program by calling this function suitably from main by creating an array with 10 arbitrary values, and call this function and display the minimum value.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter8: Arrays And Strings
Section: Chapter Questions
Problem 44SA
icon
Related questions
Question
5. Define a C++ function Min that takes an array of floating point numbers X and number of data N
(N is integer) and determines the minimum of all the values and returns the minimum value.
Now complete the program by calling this function suitably from main by creating an array with
10 arbitrary values, and call this function and display the minimum value.
Transcribed Image Text:5. Define a C++ function Min that takes an array of floating point numbers X and number of data N (N is integer) and determines the minimum of all the values and returns the minimum value. Now complete the program by calling this function suitably from main by creating an array with 10 arbitrary values, and call this function and display the minimum value.
Expert Solution
Step 1

Algorithm:

  1. Start.
  2. Create a function Min, which takes an array of floats X and an integer N, which is the size of the array.
  3. Create a float variable min_val and set it to the first element of the X array.
  4. Loop through the remaining elements of the X array, starting from the second element.
  5. For each loop, set min_val to the smaller of the two values of min_val and the current element of the X array.
  6. After the loop, return min_val.
  7. In main, create an array X of 10 floats, and set N to 10.
  8. Call the Min function, passing the X array and N, and store the returned value in a float variable min_val.
  9. Print out the min_val.
  10. End.
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Functions
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr