Here is the mini game i created named "Guessing Game"
#!/usr/bin/awk -f
BEGIN {
srand();
MIN=1;
MAX=50;
NUM=0;
TRY=5;
COUNT=1;
r=int(((rand() *(1+MAX-MIN))+MIN));
print "Please pick a number between 1-50"
while (r != NUM) {
getline NUM < "-"
if (r < NUM) {
print "Lower!"
} else if (r > NUM) {
print "Higher!"
} else {
print "Congratulations! You got the right number!\n"
exit;
}
if (COUNT == 5 && r != NUM) {
print "Sorry! Better Luck Next Time!"
print "The correct number is number " r;
exit;
}
COUNT++;
}
}
---------- Post updated at 06:13 PM ---------- Previous update was at 05:30 PM ----------
thanks for the replies but I still have trouble getting a random # set. I am most familiar with awk.. its great that there are examples that dont use awk but it would be great to show an example. sorry and thanks