Increment and decrement operator in C Programming

Increment and decrement operator

               C offers two unusual and unique operators ++  and -- called  increment and decrement operator respectively. The use of these two operators will results in the value of the variable being incremented or decremented by unity. i=i+1 can be written as i++ and j=j-1 can be written as j--

             The operators can be place either before or after the operand. If the operator is placed before the variable (++I or --I) it is known as pre incrementing or pre decrementing.

             If the operator is placed after the variable (I++ or I--) it is known as post incrementing or post decrementing.

             Pre incrementing or pre decrementing or post incrementing or post decrementing have different effect when used in expression. In the pre increment or pre decrement first the value of operand is incremented or decremented then it is assigned.

Example:
x=100;
y=++x;
After the execution the value of y will be 101 and the value of x will be 100.

            In the post increment or post decrement first the value of operand is assigned to the concern variable and then the increment or decrement perform.

Example:
x=100;
Y=x++;
After the execution the value of y will be 100 and the value of x will be 101.

Example:

Ready to get started?

Ready to embark on your journey into the world of C programming? Our comprehensive course provides the perfect starting point for learners of all levels. With engaging lessons, hands-on exercises, and expert guidance, you'll gain the skills and confidence needed to excel in this fundamental programming language. Let's dive in and unlock the endless possibilities of C programming together!