Shell Script to find Greatest of four numbers using If-Else-If Statement
Q: How do I write Bash Script to find Greatest of Four Numbers using If-Else-If Statement
Ans:
#!/bin/bash
read -p "Enter first Number:" n1
read -p "Enter second Number:" n2
read -p "Enter third Number:" n3
read -p "Enter fourth Number:" n4
if((n1>n2)) ; then
if((n1>n3)); then
if((n1>n4)); then
echo "$n1 is a Greatest Number"
else
echo "$n4 is a Greatest Number"
fi
0 comments:
Post a Comment