Written by Sai Sandeep Thota on April 20, 2013 in Programming > Shell

Shell Script to find Greatest of Three numbers

GET ALERTS:

Get our Latest updates delivered to your mailbox!

This shell script is used to find greatest of three given numbers. The conditions are very simple. Just go through the program.

echo "Enter three Integers:"
read a b c

if [ $a -gt $b -a $a -gt $c ]
then
	echo "$a is Greatest"
elif [ $b -gt $c -a $b -gt $a ]
then
	echo "$b is Greatest"
else
	echo "$c is Greatest!"
fi

Output:
greatest

{ 1 comment… read it below or add one }

vinod March 19, 2014 at 7:51 pm

HI Sandeep can you help me in the same code how to validate whether given input numbers are integers or not before comparing largest number.Thanks in advance.

Reply

Leave a Comment

Previous post:

Next post: