Friday, June 15, 2012

Shell Script to find Greatest and Smallest number


Q. How do I write shell script to find Smallest and Greatest number in an array
Ans:

#!/bin/bash
echo "enter size of an array"
read n
#taking input from user
for((i=0;ido
echo " enter $((i+1)) number"
read nos[$i]
done
#printing the entered number
echo "number entered are"
for((i=0;ido
echo ${nos[$i]}
done
#main loop
small=${nos[0]}
greatest=${nos[0]}
for((i=0;ido
#

0 comments:

Post a Comment