itec 109 lecture 11 while loops. while loops review choices –1 st –2 nd to ?th –last what...

5
ITEC 109 Lecture 11 While loops

Upload: eustacia-gibson

Post on 18-Jan-2016

213 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: ITEC 109 Lecture 11 While loops. while loops Review Choices –1 st –2 nd to ?th –Last What happens if you only use ifs? Can you have just an else by itself?

ITEC 109

Lecture 11While loops

Page 2: ITEC 109 Lecture 11 While loops. while loops Review Choices –1 st –2 nd to ?th –Last What happens if you only use ifs? Can you have just an else by itself?

while loops

Review

• Choices– 1st

– 2nd to ?th– Last

• What happens if you only use ifs?• Can you have just an else by itself?• Homework ?s– iterate + if / else if

Page 3: ITEC 109 Lecture 11 While loops. while loops Review Choices –1 st –2 nd to ?th –Last What happens if you only use ifs? Can you have just an else by itself?

while loops

Objectives

• Exam on Tuesday– True / False– Short Answer–Write a simple program– Tell me what a program does

• Learn the last intro concept–While loops

Page 4: ITEC 109 Lecture 11 While loops. while loops Review Choices –1 st –2 nd to ?th –Last What happens if you only use ifs? Can you have just an else by itself?

while loops

Problem

• Need to repeat statement(s)• Don’t know the # until program runs

Page 5: ITEC 109 Lecture 11 While loops. while loops Review Choices –1 st –2 nd to ?th –Last What happens if you only use ifs? Can you have just an else by itself?

while loops

Solution

• Use boolean variables or operations• while (boolean) do X statements

go = true;while (go):

StatementsSome statement that sets go to be false