More on Conditionals

Sort by

recency

|

342 Discussions

|

  • + 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
    
  • + 0 comments

    No and operator in condition

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