Function definition: Difference between revisions

From Rosetta Code
Content added Content deleted
(Added Toka)
No edit summary
Line 9: Line 9:
return a * b;
return a * b;
}
}

=={{header|MAXScript}}==
fn multiply a b =
(
a * b
)


=={{header|Perl}}==
=={{header|Perl}}==

Revision as of 22:38, 18 September 2007

Task
Function definition
You are encouraged to solve this task according to the task description, using any language you may know.

A function is a body of code that returns a value. The value returned may depend on arguments provided to the function.

Write a definition of a function called "multiply" that takes two arguments and returns their product.

C

double multiply( double a, double b )
{
  return a * b;
}

MAXScript

fn multiply a b =
(
    a * b
)

Perl

sub multiply( $$ )
{
  $a = shift;
  $b = shift;
  return $a * $b;
}

PHP

function multiply( $a, $b )
{
   return $a * $b;
}

Toka

[ ( ab-c ) * ] is multiply