Interviews Questions, Algorithms, Aptitude, C Interview Program, C Theory Question, Aptitude Tricks, Test Series,

Sunday 28 April 2019

IOPP Program No.1.B

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

0 comments:

Post a Comment