Commit 9b309ccc authored by Fayyaz Hussain's avatar Fayyaz Hussain

Upload New File

parent b954f95c
#!/bin/bash
arr=(90 23 73 11 5 31 129 678 7 5)
j=0
temp=0
values=10
# Declaring function
max () {
j=$1
if [ $j -lt $values ]
then
if [ ${arr[j]} -gt $temp ]
then
# swap
temp=${arr[j]}
((j++))
max $j
else
((j++))
max $j
fi
fi
}
echo "Array in original order"
echo ${arr[*]}
# calling function max
max 1
echo "Maximum value is:"
echo $temp
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment