-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththree_numbers.sh
More file actions
28 lines (22 loc) · 873 Bytes
/
three_numbers.sh
File metadata and controls
28 lines (22 loc) · 873 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/bash
# Prompt the user to enter three numbers
read -p "Enter the first number: " num1
read -p "Enter the second number: " num2
read -p "Enter the third number: " num3
# Check if all three numbers are equal
if [ "$num1" -eq "$num2" ] && [ "$num2" -eq "$num3" ]; then
echo "All three numbers are equal."
# Check if the first number is the largest
elif [ "$num1" -ge "$num2" ] && [ "$num1" -ge "$num3" ]; then
echo "The largest number is: $num1"
# Check if the second number is the largest
elif [ "$num2" -ge "$num1" ] && [ "$num2" -ge "$num3" ]; then
echo "The largest number is: $num2"
# Otherwise, the third number is the largest
else
echo "The largest number is: $num3"
fi
# Check if any two numbers are equal
if [ "$num1" -eq "$num2" ] || [ "$num1" -eq "$num3" ] || [ "$num2" -eq "$num3" ]; then
echo "At least two numbers are equal."
fi