PRE/POST INCREMENT/DECREMENT OPERATORS(Unary operators)
In programming we often require to increment value of certain variable in step of one or may require to decrement a value.
This is usually written as i=i+1 for incrementing the value of variable i or i=i-1 to decrement the value of i.
To accomplish this C language provides unary operators called as increment/decrement operators.Using these operators the above variable can be written as i++ or ++i.
If ++ is after the variable then it is called as post increment and if it is before the variable then it is called as predecrement.
In case of post increment(i++) the old value of the variable is used first and then the increment in the value of variable is done.
In preincrement the value of variable is incremented first and then this value is used in the expression.
same is in the case of decrement,i.e.pre decremant and post decrement,
denoted as --i and i--.
The idea of programming might sound like a frightening task, but don’t worry. We designed this blog so that you can get your feet wet without stepping into the deeper complexities of the programming.
This Blog is dedicated to all those people who want to learn the most basic but important Programming Language'C Programming'.
If done step wise C language is easy and fun to learn.
So lets get started.
Start reading from the First Post to understand C programming.You may read a desired topic from the labels.
Press Ctrl+D to add this page to your Favourites/Bookmarks for further reference.
Note:Your comments,queries and suggestions are welcome.Feel free to post them in the the comment boxes available after every post.
This Blog is dedicated to all those people who want to learn the most basic but important Programming Language'C Programming'.
If done step wise C language is easy and fun to learn.
So lets get started.
Start reading from the First Post to understand C programming.You may read a desired topic from the labels.
Press Ctrl+D to add this page to your Favourites/Bookmarks for further reference.
Note:Your comments,queries and suggestions are welcome.Feel free to post them in the the comment boxes available after every post.
Saturday, May 17, 2008
Increment-Decrement Operators
Subscribe to:
Post Comments (Atom)



0 comments:
Post a Comment