2.
#!/bin/bash
read -p "num1: " num1
read -p "num2: " num2
function swap(){
if ((num1>num2))
then
num1=$[num1^num2]
let num2=num1^num2
#num1=`expr $num1 \^ $num2` #expr does not support ^ op
num1=$((num1^num2))
fi
}
swap
echo $num1 $num2
3.
#!/bin/bash
read -p "Please enter a number(100-999): " num
g=$((num%10))
let s=num/10%10
b=$[num/100%10]
if ((num<100||num>999))
then
echo ERROR
elif ((g**3+s**3+b**3 == num))
then
echo YES
else
echo NO
fi
4.
#!/bin/bash
read -p "Please enter your num: " score
if ((score <= 100 && score >= 90))
then
echo A
elif ((score < 90 && score >= 80))
then
echo B
elif ((score < 80 && score >= 70))
then
echo C
elif ((score < 70 && score >= 60))
then
echo D
elif ((score < 60 && score >= 0))
then
echo E
else
echo ERROR
fi