Program to print string in reverse order

March 24, 2022 · Team EasyExamNotes · 1 min read (est.) · 0 comments

Share on WhatsApp

Q.एक ऐसा शैल program लिखिए जो कि एक string को reverse order मे print करे।Ans.read -p “Enter string:” string
len=${#string}
for (( i=$len-1; i>=0; i– ))
do
# “${string:$i:1}”extract single single character from string.
reverse=”$reverse${string:$i:1}”
done
echo “$reverse”

Discussion

Ask a question, share your thoughts or report an error.

Sign in to participate in the discussion.

Join the discussion