CSC 171 Lecture Notes - Lecture 6: For Loop

45 views2 pages
3 Feb 2017
School
Course

Document Summary

Quiz #1 question review int n=2; int b=3; Oat c=0. 0; int x=a; x+=b; x*=a++; if(a>2 && x<12) { x - - Loop variable: the thing inside the loop that changes inside a loop when we do repetitions. There are two kinds of loops in java: for loop, takes an integer as a loop variable for (initialization; termination; increment) { consists of statements. //loop body statement1; statement2; statement3: initialization: any variable can be created here, or initialized, or both. Examples of value initialization: int x=0; x=5: termination: a logical expression (t/f) that determines when to stop running the loop. As long as it evaluates to true, we continue to run the loop. !1: increment: a statement that runs at the end of each loop body to increment the loop variable. Assignment: create a garden world with a ower on the top row on every square using a loop.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related textbook solutions

Related Documents