CSE 5J Lecture Notes - Lecture 7: Infinite Loop, Modulus Guitars, Operand

100 views3 pages
20 Mar 2018
School
Course
Professor

Document Summary

Cmps 5j - lecture #7 - while loops. Integer division, whether it be with variables or with actual integers, the result will not be a decimal. The number will be rounded down to the nearest whole number (ex. The default size of width is 100 so ypos is zero until xpos is 99. Example 1: integer division int x = 5; int y = 7; int z = x/y; // x/y is about 0. 71 which rounds down to 0. Example 2: integer division application int xpos=0; void draw(){ background(0); int ypos=xpos/width; xpos = xpos + 1; ellipse(xpos,ypos, 20,20); The modulus (%) divides the operand on the left side by the operand on the right. 10%3 // the remainder is so the output is 1. 22%5 // the remainder is so the output is 2. Instead of using x = x + 1 to increment by 1, you can use x++ instead (ex.

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