# lec08 - CS125 Course Notes Lecture 8 Slide 1 Lecture 8 •...

This preview shows pages 1–7. Sign up to view the full content.

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

View Full Document

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

View Full Document

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CS125 Course Notes Lecture 8, Slide 1 Lecture 8 • Nested loops • Trouble-shooting • Repetition errors • Exiting (Savitch 3.3) CS125 Course Notes Lecture 8, Slide 2 Recall loops • while( Boolean_Expression ) { Body ; } • do { Body ; } while( Boolean_Expression ) • for ( Initialize ; Test ; Update ) { Body ; } CS125 Course Notes Lecture 8, Slide 3 Loop comparisons Unknown 1 do while Unknown while Known for Number of iterations Minimum loops Name CS125 Course Notes Lecture 8, Slide 4 Nested loops • We can nest loops inside of each other just like we did with if-else statements. CS125 Course Notes Lecture 8, Slide 5 Problem • Draw a square of asterisk ( * ) characters for a given number of rows/columns. • Sample output (num=4): **** **** **** **** CS125 Course Notes Lecture 8, Slide 6 Solution • Example: for (int y = 0; y <= num; y++) { // Draw num columns of * for // this row System.out.println(); } //draws a 4x4 square....
View Full Document

## This note was uploaded on 07/27/2009 for the course MATH 135 taught by Professor Andrewchilds during the Fall '08 term at Waterloo.

### Page1 / 19

lec08 - CS125 Course Notes Lecture 8 Slide 1 Lecture 8 •...

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

View Full Document
Ask a homework question - tutors are online