
While loop Programs in Javascript: Reverse Printing a Number
REVERSE PRINTING A NUMBER: PROGRAM: EXPLANATION: assume 123. 123%10 = remainder 3. 12% 10 = remainder 2. do, any number to divide by 10, you get he last digit. Condition (no > 0). because if you reverse The number, will end a last digit is 0, so take number > 0 We Don't know the Count, so take remainder let rem = 0. rem is remainder. Then take remainder = (rem* 10) + number % 10.Initial assigned rem value is 0. ◾rem * 10 = 0 * 10 = 0 no % 10 = 123 % 10= 3 ◾0+3=3 Number= math. floor (number/10); math floor means it give a initial quotient. example(123/10=12.3). It gives only first digit (or) round value 12. ◾Then number = (123/10) = 12 Then print The remainder. ◾ rem= 3 number= 12 ◾ 3 × 10 = 30 12% 10 = 2. (30+2=32) ◾ Then number = (12/10) = 1 ◾ Now rem= 32 number = 1 ◾ rem * 10 32*10=320 no % 10 = 1 % 10 = 1.(320+1=321) ◾ Then number = (1/10) = 0 ◾ Then goto while loop(0>0) is false. OUTPUT:
Continue reading on Dev.to Tutorial
Opens in a new tab


![[MM’s] Boot Notes — The Day Zero Blueprint — Operations from localhost to production without panic](/_next/image?url=https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1433%2F1*cD3LWDy_XXNTdZ_8GYh6AA.png&w=1200&q=75)

