Thursday, 11 December 2014

Shell Script to check whether a number is Even or Odd

Write a Shell Script to check whether a given number is Even or Odd

Solution:
echo Enter the number to check whether it is even or odd
read a
b=`expr $a % 2`
if test $b -eq 0
then
echo You entered an Even number
else
echo You entered an Odd number
fi

Execution:

No comments:

Post a Comment