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
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist