Commit 796bfc8b authored by Darshan Prabhu's avatar Darshan Prabhu

Update q4.sh

parent 2a507e36
...@@ -12,8 +12,8 @@ do ...@@ -12,8 +12,8 @@ do
count=$((count+1)) count=$((count+1))
done done
done <q4_in.txt done <q4_in.txt
avg=`expr $sum / $count`
echo $avg echo "scale=3;$sum / $count"|bc
arr2=($(echo ${array[*]}| tr " " "\n" | sort -n)) arr2=($(echo ${array[*]}| tr " " "\n" | sort -n))
...@@ -23,9 +23,7 @@ then ...@@ -23,9 +23,7 @@ then
a=${arr2[$i]} a=${arr2[$i]}
b=${arr2[$(($i-1))]} b=${arr2[$(($i-1))]}
x=`expr $a + $b` x=`expr $a + $b`
med=`expr $x / 2` echo "scale=3; $x / 2"|bc
else else
med=${arr2[$i]} echo ${arr2[$i]}
fi fi
echo $med
\ No newline at end of file
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