Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

leap year bash shell

#!/bin/bash
echo "Program to check for leap year or not"
read -p "Enter the year: " year
if [ $((year%400)) -eq 0 ]
then
        echo "$year is a leap year"
elif [ $((year%100)) -eq 0 ]
then
        echo "$year is not a leap year"
elif [ $((year%4)) -eq 0 ]
then
        echo "$year is a leap year"
else
        echo "$year is not a leap year"
fi
 
PREVIOUS NEXT
Tagged: #leap #year #bash #shell
ADD COMMENT
Topic
Name
8+6 =