Increment Operator

  Increment Operator


Problem Description

Consider the following code snippet and increment the value

Pattern = a++, a, ++a, a++, a
Logic Test Case 1

Input (stdin)
10

Expected Output

10

11

12

12

13



Logic Test Case 2

Input (stdin)
7

Expected Output

7

8

9

9

10
.



Code Area


import java.io.*;

import java.util.*;

public class TestClass {

public static void main(String[] args) { 

int a;

       Scanner g=new Scanner(System.in);

       a=g.nextInt();

         System.out.println(a++);

       System.out.println(a++);

       System.out.println(a);

       System.out.println(a++);

       System.out.println(a);

}

}

Post a comment

0 Comments