Problem 1 Hints: Maximum Number With A For Loop

Decomposing or breaking down the problem into a series of separate sub-problems makes it easier to solve:

  1. The program must iterate or loop, prompting the user and read each number. The problem specifies that the program must use a for-loop, but where the prompt and read occur and how often the loop runs depends on how we solve the next sub-problem.
  2. The program must "remember" the largest number entered during each iteration, implying a variable, which I'll Call max. The program must initialize max, and programmers can choose between two common approaches:
    1. Initialize max with the first input value
    2. Initialize max with the smallest integer value the computer can represent. There is a symbolic constant for this value, specified in the <climits> header file
  3. If you choose approach (a), then you prompt, read, and initialize max before entering the loop; the loop will iterate only nine times. If you choose (b), then the loop iterates ten times.
  4. During each iteration, compare the entered value to max, updating max if the entered value is greater.