Commit 231d74ca authored by Mayur Rathod's avatar Mayur Rathod

Creating Repo

parents
This diff is collapsed.
#!/usr/bin/bash
sort -n q4_in.txt > sorted.txt
i=0
sum=0
nums=$(<sorted.txt)
array[0]=0
for n in $nums; do
sum=$((sum+n))
i=$((i+1))
array[$i]=$n
done
echo "Mean=" $((sum/i))
echo ${array[*]} array
if [ $(($i % 2)) -ne 0 ]
then
middle=$[$((i/2))+1]
echo "Median=" ${array[$middle]}
else
ind1=$(($i/2))
ind2=$((ind1+1))
num1=${array[$ind1]}
num2=${array[$ind2]}
final=$((num1+num2))
fin=$(($final/2))
echo "Median=" "$fin"
fi
rm sorted.txt
10
20
30
10
10
50
50
50
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