Need help with Puzzle Code - cpp

So below code is getting each digit by digit and it converting it to number. It also detects the end of line or comma separated values and treats them as separate number.

My question is why we are in need of nested while loop and instead of && shouldn’t it be an || operator. I tried changing the contd., but it does seem to be working.

This problem is taken from Think like a programmer book if that helps

char digit;
    do
    {
        digit = cin.get();
        int number = digit - '0';
        digit = cin.get();
        while ((digit != 10)&&(digit != ','))
        {
            number = number * 10 + (digit - '0');
            digit = cin.get();
        }
        cout << number << " is the number entered\n";
    } while (digit != 10);
    return 0;

Sample Input: 12,2,3,4
Sample Output:
12 is the number entered
1 is the number entered
2 is the number entered
… so on.

Can some one please help with this.