Course of Raku / Essentials / The MAIN function / Exercises / Print the sum

Solution: Print the sum

This program consists of a single MAIN function that takes two typed arguments, both of each are built from the arguments from the command line.


Here is the solution:

sub MAIN(Int $a, Int $b) {
    say $a + $b;

🦋 Find the program in the file print-the-sum.raku.


Try different input numbers:

$ raku exercises/the-main-function/print-the-sum.raku 500 700

You can also try running the program without the arguments or with the arguments of different types and see what happens. We’ll talk about handling those cases in the second part of the course.

Next exercise

💪 Perimeter of a rectangle

Course navigation

Built-in functions for printing / note   |