Basic "for loop" Processing


/ Published in: Processing
Save to your folder(s)

In Processing: This is a basic example of a "for" loop. Relevant to almost any language.


Copy this code and paste it in your HTML
  1. for(int i = 0; i < 20; i++) {
  2. println(i);
  3. }
  4.  
  5. /* in a for loop first you
  6. define the int,
  7. then you type the condition
  8. i is less than 20 loop is active
  9. 3rd expression: what do you want to happen
  10. at the end of each loop, add 1 for instance
  11. i = i + 1 aka I++
  12. i = i + 2
  13. I += 2
  14. I += 3
  15. n = n - 1
  16. n --
  17. n = n - 2;
  18. n -= 2;
  19. */

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.