Question: Let's say I have a number from user, for exemple: 456789.
I know how to print in reverse the number, but I am not sure how I can stop the execution to print only 3 first reversed digits. 
What I mean is that I want to print only 987 from the given number

I have to stop somehow with break; but I am not sure how.

```
public static void main(String[] args) {

    int number= 0;
    int numberInReverse = 0;
    System.out.println("Input a number");
    Scanner sc=new Scanner(System.in);
    numar=sc.nextInt();

    while (number !=0){
        numberInReverse*=10;
        numberInReverse=numar%10;
        number/=10;
        System.out.print(numberInReverse);
    }
}

```

Answer: 
You could follow this algo:

1. modulo the number by 1000
2. reverse it
3. print
```
    System.out.println("Input a number");
    Scanner sc = new Scanner(System.in);

    int num = sc.nextInt();
    int reversed = 0, counter = 0;

    while (counter++ < 3) {
        int digit = num % 10;
        reversed = reversed * 10 + digit;
        num /= 10;

    }

    System.out.println("Reversed Number: " + reversed);

```