Course of Raku / Essentials
/ Functions essentials /
The MAIN
function / Exercises
Perimeter of a rectangle
Problem
Write a program that computes and prints the perimeter of a
rectangle. Pass the lengths of two sides in command-line arguments. If
it is a square, pass a single value. Use the MAIN
function.
Example
The program should explicitly confirm if it works with a square or a rectangle. Here is a possible output for the two cases:
$ raku perimeter.raku 15
The perimeter of a square is 60.
$ raku perimeter.raku 15 20
The perimeter of a rectangle is 70.Solution
Course navigation
← Solution: Print the sum | Solution: Perimeter of a rectangle →
Translations of this page: English • Deutsch • Español • Italiano • Latviešu • Nederlands • Български • Русский • Українська