Increment and Decrement Operators in C Language

Views: 107   

C Language supports Increment and Decrement operators which are used to add 1 or subtract 1

Operator description Example
++ Adds 1 a++
-- Subtracts 1 a--

Following is a sample program which describes the usage of Increment and Decrement Operators

#include <stdio.h>

int main() {
    int a = 10;

    printf("Initial a vale : %d \n", a);

    a++; // Using Increment operator

    printf("A value after using Increment operator : %d \n", a);

    a--; // Using Decrement Operator

    printf("A value after using Decrement operator : %d \n", a);
}

Output:

Initial a vale : 10
A value after using Increment operator : 11
A value after using Decrement operator : 10
On By