Define increment and decrement operators and its use as well as give some examples????
Share
Define increment and decrement operators and its use as well as give some examples????
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Answer:
increment and decrement operators are unary operators. In increment 1 is added to the value of the variable, for eg. i=2, ++i=(1+2)=3 [here first 1 is added to the variable then the value of the variable is taken] and i=2, i++=(2+1)=3 [here first the value of the variable is taken then 1 is added to the variable ].
In decrement 1 is substrated from the value of the variable, for eg. i=2, --i [first 1 is substrated from the value of the variable then the value is taken] and i--[here first the value of the variable is taken then 1 is substrated from the value of the variable].