Write a shell script to determine whether the year entered is a leap year or not?



echo “enter  any year ”
read num
if [ `expr $num % 100` -eq 0 ]
then
if [ `ex pr $num % 400` -eq 0 ]
then
echo "Leap year"
else
echo "Not a leap year"
fi
else
if [ `expr $num % 4` -eq 0 ]
then
echo "Leap year "
else
echo "Not a leap year"
fi
fi





OUTPUT :

enter any year
1999
Not a leap year

enter any year
2000
Leap year

Comments

Post a Comment

Popular posts from this blog

Write a program to add two number using inline function in C++?

Traversing of elements program with algorithm and Flowchart