on
TCL
- Get link
- X
- Other Apps
#!/usr/bin/tclsh
puts "Enter a number: "
gets stdin number
scan $number %d number
proc reverse_number {in} {
set num 0
while {$in > 0} {
set num [expr ($num * 10) + ($in % 10)]
set in [ expr $in/10 ]
}
puts "Reverse number: $num"
}
reverse_number $number
Enter a number:
3452
Reverse number:2543
Enter a number:
1765
Reverse number: 5671
Comments
Post a Comment