The increment operator is used to increase a value by one, while the decrement operator does the opposite of increment. The decrement operator decreases a value by one.
The following is the syntax of the pre-increment operator in C language.
++variable_name;
This is the syntax of the pre-decrement operator in C language.
--variable_name;
Let us take a look at the pre-increment operator and the predecrement operator.
Pre-increment- Before assigning the value to the variable, the value will be incremented by one.
This is an example of pre-increment in C language,
Live Demo
#include <stdio.h> int main() { int i = 5; printf("The pre-incremented value : %d</p><p>",i); while(++i < 10 ) printf("%d\t",i); return 0; }
The pre-incremented value : 5 6789
Pre-decrement-Before assigning the value to the variable, the value will be decremented by one.
Here is an example of pre-decrement in C language,
p>
Real-time demonstration
#include <stdio.h> int main() { int i = 10; printf("The pre-decremented value : %d</p><p>",i); while(--i > 5 ) printf("%d\t",i); return 0; }
The pre-decremented value : 10 9876
The above is the detailed content of In C language, pre-increment (or pre-decrement). For more information, please follow other related articles on the PHP Chinese website!