on
TCL
- Get link
- X
- Other Apps
#!/usr/bin/tclsh
puts "Enter a number: "
gets stdin input
proc count_digit {input} {
set digit 0
if {$input == 0} {
puts "It has 1 digit"
} else {
while {$input > 0} {
set input [ expr $input / 10]
incr digit 1
}
puts "It has $digit digit"
}
}
count_digit $input
Enter a number:
565
It has 3 digit
Enter a number:
608
It has 3 digit
Comments
Post a Comment