Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Selected Reading
Compound operators in Arduino
Compound operators in Arduino work just like in C, and they help save you some writing time, and also reduce the number of lines in your code. As the name seems to suggest, compound operators combine multiple operators.
The following table lists the compound operators in Arduino.
Assume that a and b are integers having values a = 5 and b = 2 in all the following examples −
| Operator | Description | Example | Output |
|---|---|---|---|
| ++ | Increment | a++ | a=6 |
| -- | Decrement | a-- | a=4 |
| += | Compound Addition | a+=b | a=7 |
| -= | Compound subtraction | a-=b | a=3 |
| *= | Compound multiplication | a*=b | a=10 |
| /= | Compound division | a/=b | a=2 |
| %= | Compound remainder | a%=b | a=1 |
| &= | Compound bitwise AND | a&=b | a=0 |
| |= | Compound bitwise OR | a|=b | a=7 |
| ^= | Compound bitwise XOR | a^=b | a=7 |
Advertisements
