-
May 13th, 2007, 07:43 AM
#1
Help with an algorithm.
Here is a simple algorithm that uses a while loop.
set theinitial valueofcount to10
while(NOT(count is 0))
write the valueofcount in theoutput window
decreasecount by 1
move to thenext lineof theoutput window
write 'zero' in theoutput window
Figure 4 An algorithm using a while loop
(a)What will be written to the output window when this algorithm
is run? [2]
(b)Suppose the second line of the algorithm were changed to read
while(count is 11)
What will be written when the modified algorithm is run? [2]
Suppose you are a given a pile of cards, each of which shows one
of the following four shapes: square or circle, shaded or unshaded
(Figure5). You can assume these are the only possibilities.
Write a set of instructions using while loop and if...else
selection structures to sort the pile of cards according to the
symbols they display and write an appropriate message for each
card, for example 'shaded circle' or 'unshaded square'. Each
message should be on a new line.
In your answer you should use indentation to help make the
structure of the algorithm clear.
-
May 13th, 2007, 08:00 AM
#2
Re: Help with an algorithm.
Please see link for important information regarding your problem.
TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
2008, 2009,2010
In theory, there is no difference between theory and practice; in practice there is.
* Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
* How NOT to post a question here
* Of course you read this carefully before you posted
* Need homework help? Read this first
-
May 13th, 2007, 08:33 AM
#3
Re: Help with an algorithm.
Actually I was just wondering which format an output would be required in regards to the 2nd question.
-
May 13th, 2007, 08:36 AM
#4
Re: Help with an algorithm.
Originally Posted by viper12
Actually I was just wondering which format an output would be required in regards to the 2nd question.
I would assume a nicely arranged textual format.
TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
2008, 2009,2010
In theory, there is no difference between theory and practice; in practice there is.
* Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
* How NOT to post a question here
* Of course you read this carefully before you posted
* Need homework help? Read this first
-
May 13th, 2007, 08:42 AM
#5
Re: Help with an algorithm.
Hehe. I'll sort that out.
On another note, do you know of any software that executes algorithms in their pure form, since I need to make sure the algorithm for the pile of cards is right.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|