Skip to content
Snippets Groups Projects
Commit 357184cd authored by Dao2.Trung@live.uwe.ac.uk's avatar Dao2.Trung@live.uwe.ac.uk
Browse files

practice 3

parent d4a05e0a
Branches
No related tags found
No related merge requests found
#/bin/bash
lsOutput=$(ls -lrt)
echo $lsOutput
echo "Enter a number "
read number
echo "It's $number"
echo "Enter a number: "
read num1
echo "Enter another number: "
read num2
if [ "$num1" = "$num2" ]; then
echo "$num1 equals to $num2"
else
if [ "$num1" -gt "$num2" ]; then
echo "$num1 is greater than $num2"
else
echo "$num1 is smaller than $num2"
fi
fi
sumNum=$((num1 + num2))
echo "$sumNum"
\ No newline at end of file
echo "Enter a number: "
read num
if [ $((num % 2)) -eq 0 ]; then
echo "$num is even"
else
echo "$num is odd"
fi
\ No newline at end of file
numbers=()
sum=0
for ((i=1; i<=10; i++)); do
read -p "Enter number $i: " num
numbers+=("$num")
sum=$((sum+num))
done
echo "The sum of the array is $sum"
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment