Rabu, 06 Juni 2012

Praktikum 4.3 Perulangan for

Gunakan perulangan for untuk menggantikan kode while pada praktikum 4.1 sehingga mendapatkan segitiga yang sama

Segitiga atas dengan "for"

<html>
<head>
           <title>Praktikum 4.Perulangan</title>
</head>

<body>
            <?php
                $tinggi = 10;
                $i = 0;
                for ($i = 0 ; $i <= $tinggi ; $i++){
                  for ($j = 0 ; $j < $i ; $j++ ){
                    echo "*";
                }
                    echo "<br>";
                }
           ?>
</body>

</html>

Output :

Segitiga atas dengan "for"

<html>

<head>
            <title>Praktikum 4.Perulangan</title>
</head>

<body>
            <?php
               $tinggi = 0;
               $i = 10;
               for ($i = 10 ; $i >= $tinggi ; $i--){
                  for ($j = 0 ; $j < $i ; $j++ ){
                     echo "*";
               }
                     echo "<br>";
               }
           ?>
</body>
</html>

Output :

1 komentar:

  1. The Biggest Online Gambling Companies in the World | DrmCD
    the biggest online gambling 김천 출장안마 companies 남원 출장마사지 in the world. by giving the platform access 창원 출장마사지 to more than 4,000 online 안양 출장안마 casino games and 광명 출장안마 offering

    BalasHapus