While Loops - Introduction to Loops While Loops While Loops...

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

View Full Document Right Arrow Icon
Introduction to Loops While Loops While Loops T. Mercker Aerospace Engineering and Engineering Mechanics The University of Texas at Austin ASE 201: Introduction to Computer Programming February 23, 2009 T. Mercker While Loops
Background image of page 1

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

View Full DocumentRight Arrow Icon
Introduction to Loops While Loops Outline Introduction to Loops While Loops Example 1 Example 2 Example 3 T. Mercker While Loops
Background image of page 2
Introduction to Loops While Loops Introduction to Loops I On many of the programs you have written thus far you have had to repeat tasks I To do this you needed to call the program many times I In programming tasks are repeated using Loops I There are two types of loops: 1. While (this week) 2. For (few weeks) I The difference comes in when the different loops are used I While loops are used when a condition is unknown I For loops are used for a known and specific set of conditions T. Mercker While Loops
Background image of page 3

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

View Full DocumentRight Arrow Icon
Introduction to Loops While Loops Example 1 Example 2 Example 3 While Loops I While loops run indefinitely until a condition is satisfied I Syntax: while ( logical expression ) Code if logical expression is true end I Loop runs while logical expression is true I Loop breaks when logical expression is false I The while loop checks the logical expression when it first enters and every time it reaches “end” I Note that logical expression can be compound just like if statements T. Mercker While Loops
Background image of page 4
Introduction to Loops While Loops Example 1 Example 2 Example 3 I Since while loops use a logical expression, two things HAVE to happen 1. The variables in the logical expression HAVE to be initialized (otherwise there is nothing to compare and while loop will not be
Background image of page 5

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

View Full DocumentRight Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/29/2009 for the course ASE 201 taught by Professor Hayes during the Spring '07 term at University of Texas.

Page1 / 14

While Loops - Introduction to Loops While Loops While Loops...

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

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