salary=(30000 45000 15000 40000)
average=37500
ans=0
for i in ${salary[@]}
do
if [ $((i<average)) ]
then
ans=$((ans+1))
fi
done
echo $ans
I am traversing through the salary array using for-loop, inside the for-loop, there is an if condition.
There are only two fields in array that suits if [ $((i<average)) ] condition, 30000 and 15000.
But it showing 4
Expected output is 2