CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    May 2007
    Posts
    9

    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.

  2. #2
    Join Date
    Mar 2002
    Location
    St. Petersburg, Florida, USA
    Posts
    12,125

    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

  3. #3
    Join Date
    May 2007
    Posts
    9

    Re: Help with an algorithm.

    Actually I was just wondering which format an output would be required in regards to the 2nd question.

  4. #4
    Join Date
    Mar 2002
    Location
    St. Petersburg, Florida, USA
    Posts
    12,125

    Re: Help with an algorithm.

    Quote 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

  5. #5
    Join Date
    May 2007
    Posts
    9

    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
  •  





Click Here to Expand Forum to Full Width

Featured