Programming Shortcut

Write, Run and execute Your programs with simple and esay way by Programming Shortcut

Monday, February 4, 2019

Increment & decrement in c Programming


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 =%d\n\n",x);
         printf("Number with postfix increment is =%d\n",x++);
         printf("After postfix increment number is =%d\n",x);
         printf("Number with postfix decrement is =%d\n\n",x--);
         printf("After postfix decrement number is =%d\n",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 =%d\n\n",x);
         printf("Number with prefix increment is =%d\n",++x);
         printf("After prefix increment number is =%d\n",x);
         printf("Number with prefix decrement is =%d\n\n",--x);
         printf("After prefix decrement number is =%d\n",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!

Programming Shortcut is collections in java best programs with example, best c programs with example and best c++ programs with example, best way to learn java, c and c++

About Programming Shortcut

This is a programming learning website that can help you learn and when your write your programming code. And all programming code is compiled run programming code in the following programming language C, c++, Java, php and Javascript Languages. find your programming read, understand the programming then copy and past and run your program and save your golden time to typing the program becuse you learn more in leas time. All Programming is codeing is ease to understand the programming