Created
October 31, 2014 14:21
-
-
Save msomu/cab8d4efbc1f8eb1ed60 to your computer and use it in GitHub Desktop.
Inc dec operators
This file contains hidden or 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 IncrementOperator { | |
| public static void main(String[] args) { | |
| Scanner sc = new Scanner(System.in); | |
| int pen = 5; | |
| int pencil = 1; | |
| //Post increment | |
| System.out.println(pen++); | |
| System.out.println(pen); | |
| //Pre increment | |
| System.out.println(++pencil); | |
| // add n to it | |
| pencil +=10; | |
| System.out.println(pencil); | |
| // mul n to it | |
| pencil *=10; | |
| System.out.println(pencil); | |
| } | |
| } |
This file contains hidden or 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
| 6 | |
| 2 | |
| 12 | |
| 120 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment