How to check whether a string is palindrome or not using TCL script?
Submitted by: AdministratorCode 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"
Submitted by: Administrator
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"
Submitted by: Administrator
set var1 "abcdcba"
set var2 {}
set var2 [join [lreverse [split $var1 {}]] {}]
if {[string compare $var1 $var2] == 0} {
puts "Polindrome"
} else {
puts "not polindrome"
}
Submitted by: Vinod
set var2 {}
set var2 [join [lreverse [split $var1 {}]] {}]
if {[string compare $var1 $var2] == 0} {
puts "Polindrome"
} else {
puts "not polindrome"
}
Submitted by: Vinod
Read Online TCL (Tool Command Language) Job Interview Questions And Answers
Top TCL (Tool Command Language) Questions
☺ | How to check whether a string is palindrome or not using TCL script? |
☺ | What is TCL? |
☺ | Where can we find the sample tcl programs? |
☺ | How do you find the length of a string without using string length command in TCL? |
☺ | How increment a character? For example, I give a and I should get b? |
Top Coding/Programming Categories
☺ | Python Interview Questions. |
☺ | OOP Interview Questions. |
☺ | Software engineering Interview Questions. |
☺ | PHP Interview Questions. |
☺ | VBA (Visual Basic for Applications) Interview Questions. |