Computer Science Canada Using parameters -- Infinite Loops |
Author: | ToTNuim [ Sat Mar 13, 2010 11:41 am ] | ||
Post subject: | Using parameters -- Infinite Loops | ||
For some reason, my code does not accept the parameters (20, 200) or any parameter that's not (negative, positive) and will go into a infinite loop. Please help! I just started computer science and I don't know how to "look for problems" in codes!
Please specify what version of Turing you are using Turing 4.1.1 |
Author: | DtY [ Sat Mar 13, 2010 11:55 am ] | ||
Post subject: | RE:Using parameters -- Infinite Loops | ||
Is that big loop just reading a number? You can already do that:
|
Author: | USEC_OFFICER [ Sat Mar 13, 2010 5:09 pm ] |
Post subject: | RE:Using parameters -- Infinite Loops |
You don't need hasch. A simple get statement is what you need. hasch only works if there is input. If not, the program will skip over that part, without stopping. That could be the problem. Also like DtY says, you already have a get statement. Why replicate it? (Which is what you are doing) |
Author: | ToTNuim [ Sat Mar 13, 2010 5:54 pm ] |
Post subject: | Re: Using parameters -- Infinite Loops |
Yeah, a "get" statement works ![]() But, the assignment was that I use this code and add "parameters" to it. Anymore suggestions? ![]() |
Author: | TheGuardian001 [ Sat Mar 13, 2010 6:05 pm ] |
Post subject: | Re: Using parameters -- Infinite Loops |
What initial value is given to the variable number (right before the start of your loop)? Will this number ever be between low and high when low is positive? |
Author: | USEC_OFFICER [ Sat Mar 13, 2010 7:01 pm ] |
Post subject: | RE:Using parameters -- Infinite Loops |
So the problem is to figure out how to modify the code to add parameters? |
Author: | TheGuardian001 [ Sat Mar 13, 2010 7:13 pm ] |
Post subject: | Re: Using parameters -- Infinite Loops |
Did you read the initial post where it said that the problem was that it wouldn't accept parameters other than (negative number, positive number)? |
Author: | Clayton [ Sat Mar 13, 2010 10:34 pm ] |
Post subject: | RE:Using parameters -- Infinite Loops |
To further expand on TheGuardian001's hint: At various points in your code, output the value of each of your variables, see what they are, and what the resulting action in your code is because of that. You should find your answer. |
Author: | ToTNuim [ Sun Mar 14, 2010 11:08 am ] |
Post subject: | Re: Using parameters -- Infinite Loops |
Oh! ![]() ![]() It WAS my initial value for "number". ![]() But ... ,instead of zero, what should I put as my initial? |
Author: | USEC_OFFICER [ Sun Mar 14, 2010 3:36 pm ] |
Post subject: | RE:Using parameters -- Infinite Loops |
What ever number works of course! @TheGuardian001: I didn't read it fully. |