Show sourcecode
The following files exists in this folder. Click to view.
databas/
dbtestforfattare.php
forms/
funktioner/
grunder/
incl/
include/
index.php
ovn_fn1.php
ovn_fn2.php
ovn_fn3.php
ovn_fn4.php
ovn_fn5.php
ovn_fn6.php
ovn_gr1.php
ovn_gr2.php
ovn_gr3.php
ovn_gr4.php
ovn_gr5.php
ovn_incl1.php
ovningar.css
resultatsidor/
ovn_fn4.php
57 lines UTF-8 Unix (LF)
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
<?php
$title = "ovn_fn4.php";
include "incl/header.php";
?>
<h1>Störst eller Minst av 3 tal</h1>
<?php
function compareNum(int $tal1, int $tal2, int $tal3, string $smallest = "") {
if ($smallest == "minsta"){
if ($tal1 <= $tal2) {
if ($tal1 <= $tal3) {
return $tal1;
}
else {
return $tal3;
}
}
elseif ($tal2 <= $tal3) {
return $tal2;
}
else {
return $tal3;
}
}
else{
if ($tal1 >= $tal2) {
if ($tal1 >= $tal3) {
return $tal1;
}
else {
return $tal3;
}
}
elseif ($tal2 >= $tal3) {
return $tal2;
}
else {
return $tal3;
}
}
}
echo "<h3>Störst av 28, 33, 11</h3>";
$result1 = compareNum(28, 33, 11);
echo "<div class=\"resultat\">$result1</div>";
echo "<h3>Minst av 55, 88, 178</h3>";
$result2 = compareNum(55, 88, 178, "minsta");
echo "<div class=\"resultat\">$result2</div>";
echo "<h3>minst av 44, 44, 88</h3>";
$result2 = compareNum(44, 44, 28);
echo "<div class=\"resultat\">$result2</div>";
?>
<?php include "incl/footer.php"; ?>