Wednesday, November 30, 2022

leap year program in bash shell script

#/usr/bin/bash

echo "Enter year"

read year

if [[ $(($year % 100)) -ne 0 ]]

#if (((year%100)!=0))

#if  [ $(($year % 100)) -ne 0 ]

then

if [ $(($year%4)) -eq 0 ]

then

echo "Leap Year"

else

echo "Not a leap year"

fi

else

if [ $(($year % 400)) -eq 0 ]

then

echo "Leap Year"

else

echo "Not a leap year"

fi

fi

No comments:

Post a Comment