Functions Flashcards
(4 cards)
1
Q
Coral’s Builtin math functions
A
- SquareRoot(x)
- RaiseToPower(x,y)
- AbsoluteValue(x)
2
Q
RandomNumber() function
A
Built-in Coral function that takes two arguments, lowValue and highValue, and returns a random integer in the range lowValue to highValue. Ex: RandomNumber(1, 10) returns a random integer in the range 1 to 10.
3
Q
SeedRandomNumbers() Function
A
A programmer can specify the seed using the function SeedRandomNumbers(), as in SeedRandomNumbers(10) or SeedRandomNumbers(99). Note that the seeding should only be done once in a program, before the first call to RandomNumber().
4
Q
!!!! Review!!!!
modulo operator (%)
A
Evaluates (division) to the remainder of the division of two integer operands. Ex: 23 % 10 is 3.
Integer only
Examples:
- 9 % 5 is 4. Reason: Since 9 = 5 * 1 + 4, the integer division 9 / 5 results in 1, and the remainder is 4.
- 70 % 7 is 0. Reason: 70 / 7 is 10 with remainder 0.
- 1 % 2 is 1. Reason: 1 / 2 is 0 with remainder 1.
- 10 % 4.0 is not valid. “Remainder” only makes sense for integer operands.