Subject: PHP

Sum of Digits of a Number Using a While Loop

Create a variable $num = 12345.

Use a while loop to calculate the sum of the digits of the number (i.e., 1 + 2 + 3 + 4 + 5) and display the result.

Select file or drag and drop

PNG, JPG, SVG

Preview