devxlogo

Using — and ++ Operators

Using — and ++ Operators

Try to use only unary operators for incrementing and decrementing variables, because they produce fewer instructions and run faster, as you can see in the following example of code:

#include using namespace std;int main() {      int a,b,c;        a=7;   a--;    b=3+(a--);      c=--b*a--;    cout         }

The output should be:

4   8   40

devx-admin

Share the Post: