More on Conditionals

Sort by

recency

|

343 Discussions

|

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