isolate digits in large number cpp 1

isolate digits in large number cpp

long a = 12345678901;
while(a > 0) {
   long b = a % 10;
   a /= 10;
}

Here is what the above code is Doing:
1. It’s creating a variable called a and assigning it the value 12345678901.
2. It’s creating a while loop that will run as long as a is greater than 0.
3. It’s creating a variable called b and assigning it the value of a modulo 10.
4. It’s reassigning a the value of a divided by 10.
5. It’s going back to step 2.

The problem with this code is that it never stops running. It gets stuck in an infinite loop!

Why?

Because a will always be greater than 0.

a will always be greater than 0 because the value of a will always be an integer.

a will always be an integer because the value of a will always be an integer divided by 10.

a will always be an integer divided by 10 because the value of a will always be an integer modulo 10.

a will always be an integer modulo 10 because the value of a will always be an integer.

a will always be an integer because the value of a will always be an integer divided by 10.

a will always be an integer divided by 10 because the value of a will always be an integer modulo 10.

a will always be an integer modulo 10 because the value of a will always be an integer.

a will always be an integer because the value of a will always be an integer divided by 10.

a will always be an integer divided by 10 because the value of a will always be an integer modulo 10.

a will always be an integer modulo 10 because the value of a will always be an integer.

a will always be an integer because the value of a will always be an integer divided by 10.

a will always be an integer divided by 10 because the value of a will always be an integer modulo 10.

a will always be an integer modulo 10 because the value of a will always be an integer.

a will always be an integer because the value of a will always be an integer divided by 10.

a will always be an integer divided by 10 because the value of a will always be an integer modulo 10.

a will always be an integer modulo 10 because the value of a will always be an integer.

a will always be an integer because the value of a will always be an integer divided by 10.

a will always be an integer divided by 10 because the value of a will always be an integer modulo 10.

a will always be an integer modulo 10 because the value of a will always be an integer.

a will always be an integer because the value of a will always be an integer divided by 10.

a will always be an integer divided by 10 because the value of a will always be an integer modulo 10.

a will always be an integer modulo 10 because the value of a will always be an integer.

a will always be an integer because the value of a will always be an integer divided by 10.

a will always be an integer divided by 10 because the value of a will always be an integer modulo 10.

a will always be an integer modulo 10 because the value of a will always be an integer.

a will always be an integer because the value of a will always be an integer divided by 10.

a will always be an integer divided by 10 because the value of a will always be an integer modulo 10.

a will always be an integer modulo 10 because the value of a will always be an integer.

a will always be an integer because the value of a will always be an integer divided by 10.

a will always be an integer divided by 10 because

Similar Posts