Program No.1.B
Write a shell script to determine the type of triangle.
Solution:
echo "Enter the first side of the triangle."
read x
echo "Enter the second side of the triangle."
read y
echo "Enter the third side of the triangle."
read z
if [ $x -eq $y ] && [ $y -eq $z ]
then
echo "Equilateral triangle."
elif [ $x -eq $y ] || [ $y -eq $z ] || [ $x -eq $z ]
then
echo "Isoceles triangle."
else
echo "Scalene triangle."
fi
Write a shell script to determine the type of triangle.
Solution:
echo "Enter the first side of the triangle."
read x
echo "Enter the second side of the triangle."
read y
echo "Enter the third side of the triangle."
read z
if [ $x -eq $y ] && [ $y -eq $z ]
then
echo "Equilateral triangle."
elif [ $x -eq $y ] || [ $y -eq $z ] || [ $x -eq $z ]
then
echo "Isoceles triangle."
else
echo "Scalene triangle."
fi
0 comments:
Post a Comment