How do you check whether a string is palindrome or not using TCL script?
Answer Posted / indu sharma
Hi!! i have written code for the above pseudo code.Check if it works!!!!!
gets stdin a
set len [ string length $a ]
set n [ expr $len/2 ]
for { set i 0 } { $i < $n } { incr i 1 } {
set b [ string index $a $i ]
set c [ expr $len - 1 - $i ]
set d [ string index $a $c ]
if {$b != $d} {
puts "not a palindrome"
exit
}
}
puts "Palindrome"
Is This Answer Correct ? | 30 Yes | 13 No |
Post New Answer View All Answers
No New Questions to Answer in this Category !! You can
Post New Questions
Answer Questions in Different Category