COMP 202 Lecture Notes - Lecture 13: Boolean Expression

20 views3 pages
jc123 and 40170 others unlocked
COMP 202 Full Course Notes
100
COMP 202 Full Course Notes
Verified Note
100 documents

Document Summary

Tracing loop code int i = 1; while(i<50){ A for loop is a while loop with a built-in" counter. The two types of loops are equivalent, and you should use whichever seems more appropriate. 64 is larger than 50, so loop ends. Then, the condition is checked again, and if true, the loop body is executed. You can leave out any or all of the above three statements/expressions. (you don"t have to put anything there). You will always have two semi-colons inside the parentheses. They never leave out the boolean expression (but you can). if you need to take away most of the statements, you should probably be using a while loop. For loops vs while loops int i=1 while(i 10) { Check if it is divisible by 2. Otherwise: check if it is divisible by 3. If it is, then it is not prime. Continue until the square root of that number!

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 Documents