More on Conditionals

Sort by

recency

|

344 Discussions

|

  • + 0 comments

    #!/bin/bash

    read X read Y read Z

    if [[ X -eq Y && X -eq Z && Y -eq Z ]];then echo "EQUILATERAL"

    elif [[ X -eq Y || Y -eq Z || X -eq Z ]];then echo "ISOSCELES" else
    echo "SCALENE"

    fi

  • + 0 comments
    #!/bin/bash
    
    read x
    read y
    read z
    if (( $x == $y )) && (( $x == $z ));
    then
        echo "EQUILATERAL"
    elif (( $x == $y )) || (( $x == $z )) || (( $y == $z ));
    then
        echo "ISOSCELES"
    else
        echo "SCALENE"
    fi
    
  • + 0 comments
    read x
    read y
    read z
    
    if [ $x -eq $y ] && [ $x -eq $z ]
    then
    echo "EQUILATERAL"
    elif [ $x -eq $y ] || [ $x -eq $z ] || [ $y -eq $z ]
    then 
    echo "ISOSCELES"
    else 
    echo "SCALENE"
    fi
    
  • + 0 comments
    read X
    read Y
    read Z
    
    if (( "$X" == "$Y" && "$Y" == "$Z" ))
    then 
        echo "EQUILATERAL"
    elif (( "$X" == "$Y" || "$Y" == "$Z" || "$Z" == "$X" ))
    then 
        echo "ISOSCELES"
    else
        echo "SCALENE"
    fi
    
  • + 0 comments
    read X
    read Y
    read Z
    
    if test $X -eq $Y -a $X -eq $Z; then
      echo EQUILATERAL
    elif test $X -ne $Y -a $X -ne $Z -a $Z -ne $Y ; then
      echo SCALENE
    else
      echo ISOSCELES
    fi