in the second expression, the count
value increments first and then it is assigned to the variable –count on the left-hand side.
We are in a position to solve an example now.
Example
1: Write a C program to show implement the concept of post- and pre-increment
operators.
Solution 1:
The program is as follows:
#include
void main( )
{
int counter, precount, postcount;
counter = 10;
precount = ++counter;
postcount= counter++;
printf(“%d %d\n”,precount,postcount);
counter=50;
postcount = counter--;
precount = --counter;
printf(“%d %d\n”,postcount,precount);
}
Do'stlaringiz bilan baham: |