Skip to content

contoh operator if pada shell programming

July 7, 2007

!/bin/bash
clear
echo “Game tebak angka”
echo “—————-”
echo “tebak angka antara 0 – 100”
f=0
hasil=22
while [ $f  = 0 ];
do
read -p “Masukkan angka tebakan anda : ” angka
if [ $angka -gt $hasil ];
then
echo “Tebakan anda terlalu besar”
elif [ $angka -lt $hasil ];
then
echo “Tebakan anda terlalu kecil”
elif [ $angka -eq $hasil ];
then
echo “Selamat tebakan anda benar !!!! ”
echo “Angka yang anda tebak $hasil ”
f=1
else
echo “Anda salah input”
fi

done

From → Linux

One Comment
  1. linggis permalink

    wah…klo ini pake shell ya.nice tut:)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: