What is wrong in following code - TCL

This is a discussion on What is wrong in following code - TCL ; //Prints a random number between the range input by the user puts "Enter the lower boundary of the range" gets stdin min puts "Enter the upper boundary of the range" gets stdin max set target [expr {int($min + rand()*($max-$min))}] puts ...

+ Reply to Thread
Results 1 to 2 of 2

What is wrong in following code

  1. Default What is wrong in following code

    //Prints a random number between the range input by the user

    puts "Enter the lower boundary of the range"
    gets stdin min

    puts "Enter the upper boundary of the range"
    gets stdin max

    set target [expr {int($min + rand()*($max-$min))}]
    puts $target

    puts "Enter a number between $min and $max"
    gets stdin usr

    if ($usr<$min || $usr>$max) {
    puts "Number that you entered in NOT in RANGE"
    exit 1
    }

    proc check {target usr} {
    if { $target == $usr } {
    puts "Correct,The number was $target. You Won"
    } else {
    puts "Wrong,The number was $target. You Lose"
    }
    }
    [check $target $usr]
    gets stdin

  2. Default Re: What is wrong in following code

    The first excecution of the loop will reduce the number to 1 - then it will loop forever.

+ Reply to Thread

Similar Threads

  1. wrong syntax when I try to set Javascript code in C# Code Behind.
    By Application Development in forum CSharp
    Replies: 5
    Last Post: 07-30-2008, 04:22 AM
  2. What's wrong with this code?
    By Application Development in forum Macromedia Dreamweaver
    Replies: 3
    Last Post: 05-21-2008, 11:48 AM
  3. What's wrong with this code ?
    By Application Development in forum Fortran
    Replies: 12
    Last Post: 10-07-2007, 06:04 PM
  4. Re: What is wrong with this code?
    By Application Development in forum C
    Replies: 0
    Last Post: 06-30-2007, 08:00 PM
  5. What is wrong with this code ?
    By Application Development in forum PHP
    Replies: 2
    Last Post: 09-15-2003, 02:29 PM