Course of Raku / Essentials / Variables and data types essentials / Ranges / Exercises
If the number is within the limits
Problem
Write a program that asks to enter three numbers:
$begin, $end, and $n and prints
True or False depending on whether
$n is in the range [$begin, $end) (including
$begin but excluding $end).
Please assume that the entered numbers satisfy the condition:
$begin < $end + 1, but do not add code to check it.
Example
The possible output of the program for both cases is shown below:
$ raku number-in-limits.raku
From (including): 10
To (excluding): 20
What is the number? 15
True
$ raku number-in-limits.raku
From (including): 10
To (excluding): 20
What is the number? 30
FalseSolution
Course navigation
← Quiz — Matching against a range | Solution: If the number is within the limits →
Translations of this page: English • Deutsch • Español • Italiano • Latviešu • Nederlands • Български • Русский • Українська