Warning: The magic method Slickr_Flickr_Plugin::__wakeup() must have public visibility in /home/kenbauer/public_kenscourses/tc101winter2015/wp-content/plugins/slickr-flickr/classes/class-plugin.php on line 152

Warning: Cannot modify header information - headers already sent by (output started at /home/kenbauer/public_kenscourses/tc101winter2015/wp-content/plugins/slickr-flickr/classes/class-plugin.php:152) in /home/kenbauer/public_kenscourses/tc101winter2015/wp-includes/feed-rss2.php on line 8
‘#f5f5dc’ Articles at Courses by Ken https://kenscourses.com/tc101winter2015 Facilitator of Learning Experiences Thu, 07 May 2015 03:37:51 +0000 en hourly 1 https://creativecommons.org/licenses/by/4.0/ Mastery22:: When to use what type of repetition in a program https://kenscourses.com/tc101winter2015/2015/mastery22-when-to-use-what-type-of-repetition-in-a-program-4/ Thu, 07 May 2015 03:37:51 +0000 https://carolinarmtz.withknown.com/2015/mastery22-when-to-use-what-type-of-repetition-in-a

#f5f5dc;">22

#f5f5dc;">Repetition structures, or loops, are used when a program needs to repeatedly process one or more instructions until some condition is met, at which time the loop ends. Many programming tasks are repetitive, having little variation from one item to the next. The process of performing the same task over and over again is called iteration, and C++ provides built-in iteration functionality. A loop executes the same section of program code over and over again, as long as a loop condition of some sort is met with each iteration. This section of code can be a single statement or a block of statements (a compound statement). (http://www.cs.fsu.edu/~cop3014p/lectures/ch5/index.html)

 

Two types of repetition structures: pretest and posttest loops

Pretest:

  1. Loop condition appears at beginning of pretest loop
  2. Determines number of times instructions w/in loop body are processed


Types of pretest loop:

  • while
  • for

Posttest:

  1. Loop condition appears at end of posttest loop
  2. Determines number of times instructions w/in loop body are processed
  3. HOWEVER, instructions processed at least once–the first time

1017

EXAMPLE!!!

Continue reading ]]>

http://www.cs.fsu.edu/~cop3014p/lectures/ch5/index.html)

 

Two types of repetition structures: pretest and posttest loops

Pretest:

  1. Loop condition appears at beginning of pretest loop
  2. Determines number of times instructions w/in loop body are processed


Types of pretest loop:

  • while
  • for

Posttest:

  1. Loop condition appears at end of posttest loop
  2. Determines number of times instructions w/in loop body are processed
  3. HOWEVER, instructions processed at least once–the first time

1017

EXAMPLE!!!

]]>
https://creativecommons.org/licenses/by/4.0/
#Mastery22 – #TC1017 https://kenscourses.com/tc101winter2015/2015/mastery22-tc1017-3/ Tue, 05 May 2015 23:58:50 +0000 https://joseeduardosanchezrosas.withknown.com/2015/mastery-22

22 1017

Two types of repetition structures: pretest and posttest loops

Pretest:

  1. Loop condition appears at beginning of pretest loop
  2. Determines number of times instructions w/in loop body are processed

#f5f5dc;">Types of pretest loop:

  1. while
  2. for

#f5f5dc;">Posttest:

  1. Loop condition appears at end of posttest loop
  2. Determines number of times instructions w/in loop body are processed
  3. HOWEVER, instructions processed at least once--the first time!

#f5f5dc;">Types of posttest loop:

  1. do...while while

#f5f5dc;">Counter-Controlled Repetition Requires

  1. the name of a control variable (or loop counter)
  2. the initial value of the control variable
  3. the loop-continuation condition that tests for the final value of the control variable to determine when to exit
  4. the control variable to be incremented (or decremented) each time through the loop

Using while Loop:

    • Executes from zero to many times, depending on expression
    • while is reserved word
    • Syntax of while statement:
while (expression)
  statement;
  • Expression provides entry condition
  • Expression (parentheses must be included as part of syntax) must evaluate to true to invoke loop statement(s)
  • Statement(s) can be simple or compound (block)
  • Statement(s) is/are body of loop
  • BE SURE to include an exit condition that will eventually evaluate expression to be false
  • Infinite loop: statement(s) continue(s) to execute endlessly
  • Loop invocation:
  1. Statement(s) execute(s) if expression evaluates to true
  2. Loop condition reevaluated
  3. Statement(s) continue(s) to execute until expression false
#f5f5dc;">Example:
int counter=1; //initialize loop control variable

while (counter 

Using for Loop:

    • Executes a set number of times determined by the counter
    • Statement can be a single statement or a compound (block) statement.
    • for is reserved word
    • Simplifies writing of count-controlled while loop
    • Syntax of for statement (for loop control statements):
for (initial statement; test statement (loop condition); update statement)
     statement;
#f5f5dc;">Example:
//printing 1 - 10 using for loop
cout 
Continue reading ]]>

22 1017

Two types of repetition structures: pretest and posttest loops

Pretest:

  1. Loop condition appears at beginning of pretest loop
  2. Determines number of times instructions w/in loop body are processed

  1. while
  2. for

  1. Loop condition appears at end of posttest loop
  2. Determines number of times instructions w/in loop body are processed
  3. HOWEVER, instructions processed at least once–the first time!

  1. do…while while

  1. the name of a control variable (or loop counter)
  2. the initial value of the control variable
  3. the loop-continuation condition that tests for the final value of the control variable to determine when to exit
  4. the control variable to be incremented (or decremented) each time through the loop

Using while Loop:

    • Executes from zero to many times, depending on expression
    • while is reserved word
    • Syntax of while statement:
while (expression)
  statement;
  • Expression provides entry condition
  • Expression (parentheses must be included as part of syntax) must evaluate to true to invoke loop statement(s)
  • Statement(s) can be simple or compound (block)
  • Statement(s) is/are body of loop
  • BE SURE to include an exit condition that will eventually evaluate expression to be false
  • Infinite loop: statement(s) continue(s) to execute endlessly
  • Loop invocation:
  1. Statement(s) execute(s) if expression evaluates to true
  2. Loop condition reevaluated
  3. Statement(s) continue(s) to execute until expression false
    • Executes a set number of times determined by the counter
    • Statement can be a single statement or a compound (block) statement.
    • for is reserved word
    • Simplifies writing of count-controlled while loop
    • Syntax of for statement (for loop control statements):
for (initial statement; test statement (loop condition); update statement)
     statement;
]]>
https://creativecommons.org/licenses/by/4.0/