Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

C. Arduino Quick Reference > COMPOUND OPERATORS

COMPOUND OPERATORS

These are special operators used to make code more concise for some very common operations like incrementing a value.

For example, to increment value by 1 you would write:

value = value +1;

but using a compound operator, this becomes:

value++;

increment and decrement (–– and ++)

These increment or decrement a value by 1. Be careful, though. If you write i++ this increments i by 1 and evaluates to the equivalent of i+1; ++i evaluates to the value of i then increments i. The same applies to ––.

+= , –=, *= and /=

These make it shorter to write certain expressions. The following two expressions are equivalent:

a = a + 5;
a += 5;

  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint