Increment & decrement in c Programming

  • on February 4, 2019
  • Likes!

Hello Friends! Welcome to my Website,
C language based programming that is for increment and decrement operator. You can use this programming both error(compiler and runtime error) free programming just copy and paste the program and save your time.

c program to understand the use of postfix increment & decrement

——start code—————
        #include<stdio.h>
        #include<conio.h>
        void main()
        {
         int x;
         printf(“Enter a Number”);
         scanf(“%d” &x);
         printf(“Number without postfix increment/decrement is =%dnn”,x);
         printf(“Number with postfix increment is =%dn”,x++);
         printf(“After postfix increment number is =%dn”,x);
         printf(“Number with postfix decrement is =%dnn”,x–);
         printf(“After postfix decrement number is =%dn”,x);
         getch();
        }
—-end code———-

 Note: The postfix increment or decrement is added one or subtracts one number from one time run the program line. It means when you use post-increment or decrement this line first print the same number and then print value addition or subtraction in the value.
Post means first print value then increment or decrement value.

 Output:

         Enter a Number 5
         Number without postfix increment/decrement is =5

         Number with postfix increment is =5
         After postfix increment number is =6

         Number with postfix decrement is =6
        After postfix decrement number is=5

Program to understand the use of prefix increment & decrement

——start code—————
        #include<stdio.h>
        #include<conio.h>
        void main()
        {
         int x;
         printf(“Enter a Number”);
         scanf(“%d” &x);
         printf(“Number without prefix increment/decrement is =%dnn”,x);
         printf(“Number with prefix increment is =%dn”,++x);
         printf(“After prefix increment number is =%dn”,x);
         printf(“Number with prefix decrement is =%dnn”,–x);
         printf(“After prefix decrement number is =%dn”,x);
         getch();
        }
—-end code———-

 Note: Pre means to increment or decrement value pre print the value.

Output:

      Enter a Number 5
      Number without prefix increment/decrement is =5

      Number with prefix increment is =6
      After postfix increment number is =6

      Number with prefix decrement is =5
      After prefix decrement number is=5

I make this programming and hope you are like the post if are you like the post you can please comment and Share the post to reach more people.
If any dought about this c programming code or input & output please comment below
If you have other question about c programming send an email by contacting us form are given on page right side.
Thank You!

Article Categories:
Programs in c

Leave a Reply

Your email address will not be published. Required fields are marked *