Hello, I am a newbie in programming and need help with a pseudo code, this is not homework I am just studying on it. Here is what I have so far
Design a while loop that generates random numbers while the numbers are greater than 0 and that counts how many random numbers are between 10 and 20 inclusively.
Start
Generate Number > 0
get Number
while Number 10-20
add 1 to count
endwhile
stop
I need something simple, would this work?
Need some help on this pseudocode please!
Page 1 of 13 Replies - 386 Views - Last Post: 18 May 2010 - 10:14 AM
Replies To: Need some help on this pseudocode please!
#2
Re: Need some help on this pseudocode please!
Posted 17 May 2010 - 09:27 PM
Not quite. Because you are supposed to design a loop to continue while rand > 0, you want the rand to be able to be < 0 at some point. Then, inside the loop, test the rand to see if it is between 10-20, then increment the counter if this is true.
#3
Re: Need some help on this pseudocode please!
Posted 18 May 2010 - 10:10 AM
macosxnerd101, on 17 May 2010 - 08:27 PM, said:
Not quite. Because you are supposed to design a loop to continue while rand > 0, you want the rand to be able to be < 0 at some point. Then, inside the loop, test the rand to see if it is between 10-20, then increment the counter if this is true.
kk The loop should continue now if the number is > 0
Start
Generate Number
While Number > 0
check number
If number is between 10 and 20 then
+1 to counter
endwhile
stop
correct? or atleast on the correct path?
This post has been edited by Xplode: 18 May 2010 - 10:12 AM
#4
Re: Need some help on this pseudocode please!
Posted 18 May 2010 - 10:14 AM
You'll want to generate a new random in the loop to avoid an infinite loop. Otherwise, your algorithm looks a lot better.
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote







|