Lecture08-w03-LIN-09202019-While_FuncPara.pdf - Computing I COMP.1010 Fall 2019 Lecture 8 While Loop By Sirong Lin PhD University of Massachusetts

# Lecture08-w03-LIN-09202019-While_FuncPara.pdf - Computing I...

• 28

This preview shows page 1 - 11 out of 28 pages.

Computing I By: Sirong Lin, PhD University of Massachusetts Lowell COMP.1010, Fall 2019 Lecture 8: While Loop
Work Ready Life Ready World Ready Computing I, F2019, By Dr. Sirong Lin Upcoming Due Dates 2 Due Date Daily 06 09-20-2019 (F), 9:00pm Week 03 Practice 09-22-2019 (Su), 9:00pm Week 04 Readings MWF, 9:00am Week 04 Practice 09-29-2019 (Su), 9:00pm Daily 07 09-23-2019 (M), 9:00pm Daily 08 09-25-2019 (W), 9:00pm HW1 10-02-2019 (W), in class
Work Ready Life Ready World Ready Computing I, F2019, By Dr. Sirong Lin Homework Packet 1 Due: 10-2-2019 (W), in class finish the questions (1~58) by yourself find classmate(s) to study together, check answers, explain difference Q&A session in class on the due date Quiz 3
Work Ready Life Ready World Ready Computing I, F2019, By Dr. Sirong Lin Outline While loop & examples Function with one parameter 4
Work Ready Life Ready World Ready Computing I, F2019, By Dr. Sirong Lin 6 Necessity of Repetition We called drawHouse() 3 times to print three houses, but what if we want to print 100 houses or 1000? drawHouse(); drawHouse(); drawHouse(); drawHouse(); Use Loop (repetition) Structure
Work Ready Life Ready World Ready Computing I, F2019, By Dr. Sirong Lin Loop/Repetition Structure A few choices in C when need to use the same code repeatedly while statement do-while statement for statement may also add more control to the loop using break statement continue statement 7
Work Ready Life Ready World Ready Computing I, F2019, By Dr. Sirong Lin Loop — while statement 8
Work Ready Life Ready World Ready Computing I, F2019, By Dr. Sirong Lin 9 while Loop Syntax Syntax while ( expression is true ) { loop body (executable statements) } while ( it is in Fall 2019 ) { we meet M/W/F; } repeat class schedule when it is in Fall 2019
Work Ready Life Ready World Ready Computing I, F2019, By Dr. Sirong Lin 10 while Loop Syntax (Cont’d) “while” is a C reserved word expression: loop repetition condition, e.g., i < 10 while ( expression is true) { loop body; (executable statements) }

#### You've reached the end of your free preview.

Want to read all 28 pages?

• Fall '15

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern