Main content
Procedures with return values
You might need: Calculator
Problem
Aarush is writing a program to help him calculate how much exercise he does at the gym.
The procedure
calcSwimYards
returns the number of yards swam for a given number of laps in a pool of a given length.PROCEDURE calcSwimYards(poolLength, numLaps)
{
lapLength ← poolLength * 2
RETURN lapLength * numLaps
}
Aarush then runs this line of code:
yardsSwam ← calcSwimYards(25, 10)
What value is stored in
yardsSwam
??
Related content