Write a program to print a string in the reverse order.

clear
echo "Enter the string to reverse it"
read str
len=`echo $str | wc -c`
len=`expr $len - 1`
echo "The reversed String is "
while [ $len -gt 0 ]
do
ch=`echo $str | cut -c $len`


echo "$ch \c"
len=`expr $len - 1`
done
echo


OutPut
Enter the string to reverse it
Jaisha
The reversed String is
a h s i a J

No comments:

Post a Comment