Check Number Is Even Or Odd in Shell Script - CodeXRitik

Check The Number Is Even Or Odd :

  • Input  : 4
  • Output :The Number is Even
Code: 1st Method
#check the number is even or odd
echo 'Enter the Number :'
read Num
test $(($Num % 2)) == 0 && echo Number is Even || echo Number is Odd



  • 2nd Method
echo 'Enter the Number :'
read Num
if [ $(($Num % 2)) == 0 ]
then
    echo Number is Even
else
    echo Number is Odd
fi



Click On Image For Program Image View 
                                             




🙏THANKS FOR VISIT🙏

 
Check Number Is Even Or Odd in Shell Script - CodeXRitik Check Number Is Even Or Odd in Shell Script - CodeXRitik Reviewed by CodexRitik on July 30, 2020 Rating: 5

1 comment:

Powered by Blogger.