Increment and Decrement Operators

Increment operators
Increment Operator is ++. ++ means +1. It increments the value 1.
Increments are two types.
1. Pre Increment
2. Post Increment
Pre increment:- Pre increment means before the variable if you ++ operator is called pre increment.
Ex:-++pi;
First it increments the value and it goes to other action.
Post increment:- Post increment means after the variable if you use ++ operator is called post increment.
Ex:- poi++;

First it goes to other action then it increments the value.


Ex 1:- pre and post increment operators example











output











Ex 2:- pre and post increment operators example











output











Ex 3:- pre increment operator example












output












Decrement operators
Decrement Operator is --. --means -1. It decrements the value 1.
Decrement operators are two types.
1. Pre Decrement
2. Post Decrement
Pre Decrement:- Pre decrement means before the variable if you use -- operator is called pre decrement.
Post decrement:- Post decrement means after the variable if you use -- operator is called post decrement.

pre and post decrement example

No comments:

Post a Comment