8. Minimum Value Algorithm
Exercises
- Write a program that reads in 7 different numbers, then prints out the smallest value and also prints out the position of the smallest value in the input sequence as a number from 1 to 7. If you need a hint, see the footnote[*].
- Write a program that reads in 7 numbers and prints out both the smallest and the greatest value of the 7 given values. All the numbers should be input by the user only once, of course. If you need a hint, see the footnote[*].
When a program finds an up-until-now smallest value, store the value of the loop variable in another variable. Do not forget to use a statement block!
Read in the first value into the variable inputValue
. Then make both the minimum
and maximum
be equal to that value, for starters. In the for
loop, you will need two if
statements, one for tracking the minimum and one for the maximum.