public class Sample {
public static void main(String[] args) {int a, b, c, d, e;
Scanner s = new Scanner(System.in);
System.out.print("Enter any integer a:");
a = s.nextInt();
b = ++a;
System.out.println("Result after Pre Increment a:"+a);
System.out.println("Result after Pre Increment b:"+b);
c = a++;
System.out.println("Result after Pre Increment a:"+a);
System.out.println("Result after Post Increment c:"+c);
d = --a;
System.out.println("Result after Pre Increment a:"+a);
System.out.println("Result after Pre Decrement d:"+d);
e = a--;
System.out.println("Result after Pre Increment a:"+a);
System.out.println("Result after Post Decrement e:"+e);
}
}
OUTPUT:
Enter any integer a:12
Result after Pre Increment a:13
Result after Pre Increment b:13
Result after Pre Increment a:14
Result after Post Increment c:13
Result after Pre Increment a:13
Result after Pre Decrement d:13
Result after Pre Increment a:12
Result after Post Decrement e:13
java +
点赞
收藏