C Language

May 26, 2023

How to use prefix increment decrement in c language

program to use prefix increment decrement in c language


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

output


a=6     a=7     a=7     a=6     a=6

Steps Description

  1. Declare integer variable a=6
  2. Initialize in integer variable a=6
  3. printf inbuild function to display value of variable a in decimal placeholder %d a = 6 for
    formatting tab separator \t is used
  4. printf inbuild function to display prefix increment values variable a in decimal placeholder
    %d a = 7 for formatting tab separator \t is used
  5. printf inbuild function to display value of variable a in decimal placeholder %d a = 7 for
    formatting tab separator \t is used
  6. printf inbuild function to display prefix decrement values variable a in decimal placeholder %d a = 6 for formatting tab separator \t is used
  7. printf inbuild function to display value of variable a in decimal placeholder %d a = 6 for
    formatting tab separator \t is used

by : Ajaj Khan

Quick Summary:

use prefix increment decrement in c language