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 ?    28 Yes 12 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Hi all, Is there any certification exams available for TCL and Perl. If so please let me know, my mailid is vpbharathi@gmail.com. Thanks in advance, Bharathi.P

2529