forked from assembler-institute/php-basics
-
Notifications
You must be signed in to change notification settings - Fork 0
/
maths.php
48 lines (37 loc) · 1.27 KB
/
maths.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
//Define a variable whose value is the result of the function that returns an absolute value.
function returnAbsoluteValue($a) {
return abs($a);
}
$absolute = returnAbsoluteValue(-20);
echo $absolute;
echo "<br><br>";
//Define a variable whose value is the result of the function that returns a rounded value to the next highest integer.
function roundValueToNextHighestInteger($a) {
return ceil($a);
}
$rounded = roundValueToNextHighestInteger(5.1);
echo $rounded;
echo "<br><br>";
//Define a variable whose value is the result of the function that returns the highest value of a series of values that are received by parameter.
function returnHighestValue($a) {
return max($a);
}
$highest = returnHighestValue([4,10,2,8]);
echo $highest;
echo "<br><br>";
//Define a variable whose value is the result of the function that returns the lowest value of a series of values that are received by parameter.
function returnLowestValue($a) {
return min($a);
}
$lowest = returnLowestValue([4,10,2,8]);
echo $lowest;
echo "<br><br>";
//Define a variable whose value is the result of the function that returns a random number
function randomNumber($x, $y) {
return rand($x, $y); //mt_rand()
}
$random = randomNumber(1,10);
echo $random;
echo "<br><br>";
?>