Saturday, 8 March 2014

Unix program to check whether a given number is even or odd.



Unix program to check whether a given number is even or odd.

clear
echo "Enter the number to find whether even or odd"
read a
if [ `expr $a % 2` -eq 0 ]
then
echo "The number $a is even"
else
echo "the number $a is odd"
fi


Output
Enter the number to find whether even or odd
13
the  number 13 is odd

Enter the number to find whether even or odd14
the number 14 is Even

No comments: