05-C-Repetition - ECE 175: Computer Programming for...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
ECE 175: Computer Programming for Engineering Applications Repetition and Loop Statements
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
ECE 175: Computer Programming for Engineering Applications - Repetition Repetition in programs The statements to be repeated is called "loop body" Identifying the need and kind of loops 1. Were there any steps I repeated as I solved the problem? If so, which ones? 2. If the answer to #1 is yes, did I know in advance how many times to repeat the steps? 3. If the answer to #2 is no, how did I know how long to keep repeating the steps? 2
Background image of page 2
ECE 175: Computer Programming for Engineering Applications - Repetition Loop kinds Counting loop Can determine the number of loop repetitions required before executing the loop Sentinel-controlled loop Input of a list of data of any length ended by a special value Endfle-controlled loop Input of a single list of data of any length from a data Fle Input validation loop Repeated interactive input of a data value until a value within the valid range is entered General conditional loop Repeated processing of data until a desired condition is met 3
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
The while statement Incrementing and decrementing counters --x same as x = x - 1; ++x same as x = x + 1; x+=k same as x = x + k; Same is true for *, / , %
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 13

05-C-Repetition - ECE 175: Computer Programming for...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online