This is a C program to test increment and decrement operators.
Increment operator increases the value by 1.
Decrement operator decreases by 1.
There are two types of increment and decrement operators ( pre and post)
++a preincremeent (first increments the value for processing)
a++ postincrement ( first time same value of a is used , then for after use it increments by 1)
--a preincrement (first decrements the value for processing)
a-- postincrement( first time same value of a is used , then for after use it decrements by 1)
PROGRAM :
#include <stdio.h> #include <stdlib.h> int main() { int number,postdecrement,preincrement,predecrement,postincrement; printf("Enter any number :\t"); scanf("%d",&number); preincrement = ++number; predecrement = --number; postincrement = number++; postdecrement = number--; printf("\n\t"); printf("Preincrement is %d \n\t",preincrement); printf("Predecrement id %d \n\t",predecrement); printf("Postincrement id %d \n\t",postincrement); printf("Postdecrement id %d \n\t",postdecrement); printf("The value of entered number is %d\n\t",number); return 0; }OUTPUT :