Search⌘ K
AI Features

Challenge 1: Sum of Two Numbers

Explore how to define and use subroutines in Perl by creating a function that sums two numbers. This lesson helps you understand passing parameters and returning results within subroutines through hands-on practice.

Problem statement

Write a subroutine sum that takes two integer parameters and returns their sum.

Input

Two numbers.

Output

Sum of the two numbers.

Sample input

4, 5

Sample output

9

Coding exercise

Write your code in the code widget below. If you don’t get it right, don’t fret; the solution is also given.

Perl
sub sum{
# write your code here
return -1;
}