Example Program 1

The example shown below illustrates the use of parameter passing in a computer program.

In this case the CalcAreaOfCircle function is passed the value of 10, 15 and then 22.

<html>
<head>
<script type='text/javascript'>

function CalcAreaOfCircle(Radius)
{ // begin CalcAreaOfCircle
var Area;

Area = Radius * Radius * 3.14 ;

alert ('The area of this circle = ' + Area)  ;

} // end CalcAreaOfCircle

// Main program
CalcAreaOfCircle(10) ;
CalcAreaOfCircle(15) ;
CalcAreaOfCircle(22) ;

</script>
</head>
<body>
</body>
</html>

Next: Example Program 2