Melayani Dengan Nurani

IA

22 Oktober 2016

Memisahkan Integer Menjadi Ganjil dan Genap dengan PHP

<html>
<head>
<script language="javascript">
function submit_form2(){
document.form2.submit();
}
</script>

<title>Ganjil-Genap</title>
</head>
<body>
<form name="form2" method="post" >
  Masukan Angka/bilangan :
 <input name="bilangan" type="text" id="bilangan" onChange="submit_form2()">
</form>
<?php
if (isset($_POST['bilangan']))
   {
   $bilangan=$_POST['bilangan'];

   $ibil =  intval($bilangan);

   for ($i=1; $i<=$ibil; $i++ ) {
      $sisa = $i % 2;
 if ($sisa==1)
   {
         echo ($i." Bilangan Ganjil " ); echo '<br>';
}
 else {
    echo ($i." Bilangan Genap " ); echo '<br>';
         }
 }
   }
?>

</body>
</html>

1 komentar:


  1. I'm gone to say to my little brother, that he should also pay a quick visit this webpage on regular basis to get updated from hottest news. hotmail email sign in

    BalasHapus

Nuhun sudah komentar