> ## Documentation Index
> Fetch the complete documentation index at: https://learn.acadlink.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Sum of Digits

> Find the sum of digits of a number using a while loop.

## Problem Statement

Write a C program that takes an integer as input and finds the sum of its digits using a while loop.

## Solution

```c theme={null}
#include <stdio.h>

int main() {
    int n, sum = 0;
    scanf("%d", &n);
    while (n > 0) {
        sum += n % 10;
        n /= 10;
    }
    printf("Sum = %d\n", sum);
    return 0;
}
```

## Input

```
1234
```

## Output

```
Sum = 10
```
