1 / 4

Introduction to Computers and Programming Lecture 10: For Loops Professor: Evan Korth New York University

Introduction to Computers and Programming Lecture 10: For Loops Professor: Evan Korth New York University. Road map. Nested for loops Reading: Liang 6: Chapter 4: 4.6 Liang 7: Chapter 4: 4.6. Nested For Loops. It is also possible to place a for loop inside another for loop.

honoria
Download Presentation

Introduction to Computers and Programming Lecture 10: For Loops Professor: Evan Korth New York University

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction to Computers and ProgrammingLecture 10: For LoopsProfessor: Evan KorthNew York University

  2. Road map • Nested for loops • Reading: • Liang 6: Chapter 4: 4.6 • Liang 7: Chapter 4: 4.6

  3. Nested For Loops • It is also possible to place a for loop inside another for loop. int rows, columns; for (rows = 1; rows <= 5; rows++) { for (columns=1; columns<=10; columns++) System.out.print ("*"); System.out.println (); } Output: ********** ********** ********** ********** ********** Outer Loop Inner Loop

  4. Nested For Loops, Example #2 int rows, columns; for (rows=1; rows<=5; rows++) { for (columns=1; columns<=rows; columns++) System.out.print ("*"); System.out.println (); } Output: * ** *** **** ***** Outer Loop Inner Loop

More Related