top of page

Incrementing Variables

Instead of using variable = variable + 1 to increment a variable we can use the increment operator ++

Example:

Output:

incrementing2.png
incrementing1.png

The output adds one number as expected per loop until the loop is no longer valid.

Order of Operations

When performing some tasks it is important to remember order of operations. As we previously incremented with variable++ we can also increment with ++variable This will add one to the function before the function is carried out.

Example:

Output:

incrementing4.png
incrementing3.png

The program will make y equal to a before a is incremented to 1 whereas z will be equal to b after it is incremented to 1.

  • Twitter
  • LinkedIn
  • discord-logo--v2
  • kisspng-github-pages-logo-repository-fork-github-logo-1-magentys-5b69de71b51265

Dragon Eye Intelligence LLC

bottom of page