C Language

May 26, 2023

How to use postfix Increment and decrement in c language

program to use postfix Increment and decrement in c language


#include<stdio.h>
int main()
{
    int s=10;
    printf("s=%d\t",s);
    printf("s=%d\t",s++);
    printf("s=%d\t",s);
    printf("s=%d\t",s--);
    printf("s=%d\n",s);
    return 0;
}

output


s=10     s=10     s=11     s=11     s=10 

Steps Description

  1. Declare integer variable S=10
  2. Initialize in integer variable S=10
  3. printf inbuild function to display value of variable S in decimal place holder %d S = 10
    for formatting tab separator \t is used
  4. printf inbuild function to display postfix increment values variable S in decimal
    place holder %d S = 10 for formatting tab separator \t is used
  5. printf inbuild function to display value of variable S in decimal place holder %d S = 11
    for formatting tab separator \t is used
  6. printf inbuild function to display post decrement values variable S in decimal place holder %d S = 11 for formatting tab separator \t is used
  7. printf inbuild function to display value of variable S in decimal place holder %d S = 10
    for formatting tab separator \t is used

by : Ajaj Khan

Quick Summary:

use postfix Increment and decrement in c language