Programming Tutorials

(追記) (追記ここまで)

Check for leap year in Shell Script

By: Vivek G in Linux Tutorials on 2011年01月29日 [フレーム]

This shell script accepts a year and checks if the entered year is leap year or not.
year=0
echo -n "Enter the year, I will tell you whether its Leap year or Not? "
read year
ans=$(($year % 4)) # or try ans=`expr $year % 2`
if [ $ans -eq 0 ]; then
 echo "$year is Leap Year"
else
 echo "$year is NOT Leap Year"
fi



(追記) (追記ここまで)


Add Comment

JavaScript must be enabled for certain features to work
* Required information
1000

Comments

No comments yet. Be the first!

Most Viewed Articles (in Linux )

Latest Articles (in Linux)

(追記) (追記ここまで)
(追記) (追記ここまで)

Related Tutorials

AltStyle によって変換されたページ (->オリジナル) /