Decrement operator in C++ by R4R Team

Decrement operator:

-Denoted by --
-this operator are able to decrease the variable value by 1

Type:
post decrement(i--)
pre decrement(--i)

Example-
i=3;
i--;
//Now value of i is 2
--i;
//Now value of i is 1

program-

#include
int main()
{
int i=10;
cout<<"i="< i--; // i=i+1
cout<<"i="< --i;
--i;
i--;
cout<<"i="< }


output-

i=10
i=9
i=6

-In this program, we start with i=10, then print the value of i after apply decrement operator and result will show in above output.




Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!