Loops 9

Description

The purpose of this challenge is to use nested for 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.
  3. Using nested for 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 for loops for this part of the exercise.
  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-LOOP0009

Print Requirements