# C Program to Find Sum of Digit of Number Using Recursive Function

This C program finds sum of digit of a given number by user using recursive function call.

``````
#include<stdio.h>

int digitSum(int );

int main()
{
int number, sum;

printf("Enter number: ");
scanf("%d", &number);

sum = digitSum(number);

printf("Sum of digit of %d is %d.", number, sum);
return 0;

}

int digitSum(int n)
{
if(n < 10)
{
return n;
}
else
{
return n%10 + digitSum(n/10);
}
}

``````

Output

```Enter number: 976
Sum of digit of 976 is 22.
```
{"ft_lang_label":"__label__en","ft_lang_prob":0.54725814,"math_prob":0.9981462,"size":498,"snap":"2023-40-2023-50","text_gpt3_token_len":140,"char_repetition_ratio":0.17611337,"word_repetition_ratio":0.0,"special_character_ratio":0.33333334,"punctuation_ratio":0.17757009,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9998254,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-11-28T09:44:15Z\",\"WARC-Record-ID\":\"<urn:uuid:d8106e77-a10d-45eb-8b78-3067c0e57280>\",\"Content-Length\":\"111152\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:f403f92d-608e-42bb-88aa-625ac4b367a2>\",\"WARC-Concurrent-To\":\"<urn:uuid:939a6e6b-aa93-41d7-b5c0-cf81710a83eb>\",\"WARC-IP-Address\":\"167.99.160.99\",\"WARC-Target-URI\":\"https://www.codesansar.com/c-programming-examples/find-sum-digit-number-using-recursive-function.htm\",\"WARC-Payload-Digest\":\"sha1:IJB2SFNGB3CF4OXVXLH2BDRCZ6PH4I33\",\"WARC-Block-Digest\":\"sha1:43YECQ7LRYYVET6ZHYE3CKSB3EDM5AOT\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-50/CC-MAIN-2023-50_segments_1700679099281.67_warc_CC-MAIN-20231128083443-20231128113443-00833.warc.gz\"}"}