1. sum of digits in a number (while loop) please explain

Hey all...also, i've started assembly on Intel 64 after dipping into C on FreeBSD for the past year. Would like to start using GDB.

Code:
```// Program to give sum of digits of a number

#include <stdio.h>

int main(void)
{
long num, temp, digit, sum = 0;

scanf("%ld", &num);

temp = num;

// num = 103

while ( num > 0)
{
digit = num % 10;
sum = sum + digit;
num /= 10;
}

printf("Given number = %ld\n", temp);

// output 103, 4

printf("Sum of the digits %ld = %ld\n", temp, sum);
}```
specifically, this while loop:

Code:
```    while ( num > 0)
{
digit = num % 10;
sum = sum + digit;
num /= 10;
{```
Is this while loop looping num times until it reaches the value of greater than 0? Please expain.

103 % 10 = 3 (digit)
0 (sum) = 0 (sum) + 3
103 (num) = 103 (num) / 10 (compound operator, division)

Sincerely, lost

2. Since you mentioned GDB, are you asking for an explanation of how you can use GDB to find the answer to your question?

Note that your question was probably phrased wrongly: the while loop condition is num > 0, so the loop always loops once until it reaches the value of num greater than 0, otherwise it never loops at all and also never reaches the value of num greater than 0. Perhaps you want to ask if the loop loops num times until it reaches the value of num not greater than 0, but it is easy to see that this loop does not loop 103 times, which is why I'm wondering if your question is really about GDB.

3. I was just going on about my progress with C and I mentioned GDB. Please excuse the confusion.

Was just looking or an explanation of the while loop line by line.

4. You may want to recheck this calculation...
Code:
`103 (num) = 103 (num) / 10 (compound operator, division)`