my $random = int (rand(100)); $count = 0; while ($random != $choice) { print "enter your choice = "; $choice = <STDIN>; $count++; print "you entered= $choice"; if($choice == $random) { print "Bravo-------------------you win"; print "\nTotal number of counts= $count\n"; exit; } elsif ($choice gt $random) { print "\nyour choice is TOO High\n"; } else { print "\nyour choice is too low\n"; } print "\nto quit press q OR press enter to continue "; $value = <STDIN>; if($value eq "q\n") { print "Sorry!! you lost :-(\n"; print "\nTotal number of counts= $count\n"; exit; } }
In reply to Re: Number Guessing Game
by Shaveta_Chawla
in thread Number Guessing Game
by randomhero1270
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |