Loops 9b

Description

The purpose of this challenge is to use nested loops. This challenge will evaluate the divisibility relationship between a range of numbers.

Requirements

  1. Declare two int variables, limit and divisor
  2. Ask the user to enter values for these two variables. Use input validation to ensure that divisor is greater than zero. You can use either while or do-while for the input validation. Note that this part is not nested.
  3. Using a pair of nested loops, evaluate the divisibility of every number between 1 and limit against every number up to divisor, but only show a message if the numbers are divisibleYou must use one do-while loop and one while loop for this part of the exercise; you decide which loop type to use on the inner loop and which to use for the outer loop.
  4. See sample interaction/output below

Do Not Use

You may not use the break statement to terminate any loops

Sample Interaction / Output

Enter limit value: 5
Enter divisor value: 0
Divisor range cannot include zero
Enter divisor value: 2

1 is divisible by 1
2 is divisible by 1
2 is divisible by 2
3 is divisible by 1
4 is divisible by 1
4 is divisible by 2
5 is divisible by 1

LEGEND
PROGRAM OUTPUT
USER INPUT
FROM INPUT

CATALOG ID: CPP-LOOP0009B

Print Requirements