Monday 9 July 2012

Write a shell script to find whether a given number is even or odd.

Script-4
   

read num
if [ `expr $num % 2` -eq 0 ]
then
echo "$num is Even."
else
echo "$num is Odd."
fi
--------------------------------------------------------------------------------------------------------------
Enter a number:
8
8 is Even.

0 comments:

Post a Comment