Menu
Coddy logo textTech

Recap - True or False

Part of the Fundamentals section of Coddy's Ruby journey — lesson 33 of 88.

challenge icon

Challenge

Easy

Read three integers from the user as input:

  1. A number to check
  2. A lower bound
  3. A upper bound

Determine if the first number falls within the range (inclusive) defined by the lower and upper bounds. Print the result as true or false.

Use comparison operators and the logical && operator to check if the number is greater than or equal to the lower bound AND less than or equal to the upper bound.

For example, if the inputs are 15, 10, and 20, the output should be:

true

If the inputs are 5, 10, and 20, the output should be:

false

Try it yourself

# Read input
number = gets.chomp.to_i
lower_bound = gets.chomp.to_i
upper_bound = gets.chomp.to_i

# TODO: Write your code below
# Check if number is within the range (inclusive) using && operator


# Output the result
puts result

All lessons in Fundamentals