Created
May 29, 2021 10:18
-
-
Save MrRahulR/81a5dcef3978c554a3f984d1fda26f50 to your computer and use it in GitHub Desktop.
IncrementDecrementOperator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
public class IncrementDecrementOperator { | |
public static void main(String[] args) { | |
int a; | |
//Scanner class object which is used to take input from the user. | |
Scanner scanner = new Scanner(System.in); | |
//Take value of "a" from the user. | |
System.out.print("Enter value of a : "); | |
a = scanner.nextInt(); | |
System.out.println("Value of a : " + a); | |
System.out.println("Increment after performing ++a is " + ++a); | |
System.out.println("Increment after performing a++ is " + a++); | |
System.out.println("Decrement after performing --a is " + --a); | |
System.out.println("Decrement after performing a-- is " + a--); | |
} | |
} | |
/* | |
Output : | |
Enter value of a : 10 | |
Value of a : 10 | |
Increment after performing ++a is 11 | |
Increment after performing a++ is 11 | |
Decrement after performing --a is 11 | |
Decrement after performing a-- is 11 | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment