Mar 17, 2012 at 10:15am UTC
I'm struggeling with this while loop cause I feel they don't give me enough info. I'm suppose to write a while loop about the folloing info:
Two variables: results and programsDone.
Loop must execute until result is greater or equal to 50 and programsDone greater or equal to 5.
Please help.....
Mar 17, 2012 at 10:28am UTC
They give you enough info to write the while loop control expression. Now you can stop feeling like they don't.
Make an attempt.
Mar 17, 2012 at 10:38am UTC
Ok well I'm new to this so don't laugh if I do it wrong. If u right is like this:
While (result >=50) || (programsDone >=5)
Is there anything wrong?
Mar 17, 2012 at 11:38am UTC
It's right in front of you:
Stephie22 wrote:Two variables: results and programsDone .
Stephie22 wrote:Loop must execute until result is greater or equal to 50 and programsDone greater or equal to 5 .
Wazzak
Last edited on Mar 17, 2012 at 11:38am UTC
Mar 17, 2012 at 12:21pm UTC
Thanx for the help, knew I was doing something wrong.
Mar 31, 2012 at 8:06am UTC
Hi,
Should it not be
while (result < 50 && programsDone < 5)
{
// Stuff here
}
as it should execute until the values are greater than or equal to 50 or 5?
Also very new here.
Thanks
Last edited on Mar 31, 2012 at 8:17am UTC
Mar 31, 2012 at 11:13am UTC
Yes, Rascal, you are right.
As long result is smaller than 50 the loop must execute. The same for programsDone. If one of them exceeds the limit the AND-condition is not true and the loop will still continue until both are greater or equal to the limits.
Last edited on Mar 31, 2012 at 11:14am UTC