6.14.1. Functions With Loops

While studying the solutions, focus on

Problem Hints Solution
  1. Write a function that prompts the user for and reads 10 integers, one at a time, and returns the largest integer. The user may enter any legal integer value. Use a for-loop.
max1 hints max1
  1. Write a function that prompts the user for and reads integers one at a time and returns the largest integer. The user enters a -1 to end input. All other data values entered are non-negative (i.e., 0 or positive). Return -1 if the user enters no data. Use a while-loop.
max2 hints max2
  1. Write a function that prompts the user for and reads integers one at a time and returns the largest integer. The user enters a -1 to end input. All other data values entered are non-negative (i.e., 0 or positive). Return -1 if the user enters no data. Use a do-while-loop.
max3 hints max3
  1. Write a function that prompts the user for and reads 10 integers one at a time and returns the average of the numbers. The user may enter any legal integer value. Use a for-loop.
Average definition & problem hints ave1
  1. Write a function that prompts the user for and reads integers one at a time and returns the average of the numbers. The user enters a -1 to end input. All other data values entered are non-negative (i.e., 0 or positive). Return -1 if the user enters no data. Use a while-loop.
ave2
  1. Write a function that prompts the user for and reads integers one at a time and returns the average of the numbers. The user enters a -1 to end input. All other data values entered are non-negative (i.e., 0 or positive). Return -1 if the user enters no data. Use a do-while loop.
ave3