Hope you get good knowledge how to find maximum among three number. Now we will use that concept to solve this problem. Here I submit a sample shell program which can solve our problem.
echo "Enter Number 1:-"
read a
echo "Enter Number 2:-"
read b
echo "Enter Number 3:-"
read c
gcd=1
if [ $a -ge $b ]
then
s=$a
else
s=$b
fi
if [ $s -ge $c ]
then
t=$s
else
t=$c
fi
i=1
while [ $i -le $t ]
do
d=`expr $a % $i`
e=`expr $b % $i`
f=`expr $c % $i`
if [ $d -eq 0 -a $e -eq 0 -a $f -eq 0 ]
then
gcd=$i
fi
i=`expr $i + 1`
done
echo "The GCD of $a,$b and $c is $gcd"
Now write the above code in any text editor and run it.
-------------------------------------------------------------------------------------------------------------------------------
Human do error, please email:- webmaster@piyadas-world.com if you find any. Please visit http://www.piyadas-world.com for more resource.
0 comments
Post a Comment