Yahoo Answers is shutting down on 4 May 2021 (Eastern Time) and the Yahoo Answers website is now in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

Creative ways to explain iteration and selection in C++?

I'm doing a presentation and was wondering if anyone had some good ways to explain iteration and selection besides the basic stuff you can read in a book (boring!)

Also, are iteration and while loops used in popular video games today? (or at least something like them) Something like in Mariocart, if you get too far ahead, a blue shell will be release knocking you back.

Thanks for your help! I'm not really good with the creative stuff

1 Answer

Relevance
  • Anonymous
    1 decade ago
    Favourite answer

    Iteration and selection are standard parts of nearly all programming languages, and they all do it pretty much the same way. Getting creative with a description is hard, because it's basically two things:

    Iteration is the process of repeating an event as long as a certain condition exists. For example, if you step through an array (a list) of values and perform a specific action on each of them, you do this until each item in the list has been used, or you've exhausted the number of items in the list. The iteration part is determining the length of the list, then performing the command that many times.

    Selection is simply performing a command based on a specific condition. the example you used is a good one: the shell appears based on where the cart is. Yes, nearly all programs that are more than a few lines of code use one or the other.

Still have questions? Get answers by asking now.