Write a recursive function in C language to calculate the sum of all digits in a long integer provided as input.
To write a recursive function in C language that calculates the sum of all digits in a long integer, we can follow these steps:
1. Define the recursive function prototype.
2. Define the base case.
3. Define the recursive case.
Here's the code for the recursive function:
```c
#include <stdio.h>
// Recursive function to calculate the sum of digits
int sumOfDigits(long num);
int main() {
long num;
printf("Enter a long integer: ");
scanf("%ld", &num);
_____ ______ ______ _________ _____ _________ ____ _________ _______ __________ __________ ___.
____ _________ __________ ______ ______ ____.
____ ______ _________ __________ _____ _______ ____ ______ ______ ____ ___ _____.
_________ ____ ______ ___ _________ ______ _________ _____ _____ _____ _____ __________.
______ ___ _____ _________ __________ ___.
_________ _____ ________ ___ ________ ______ _______ _____ _________ ___.
______ ________ __________ ____ _____ ________ _______ ______ __________ _____.
__________ ______ ____ __________ _____ ________ _______ _____ ___ __________ __________.
___ __________ __________ _____ ____ ____ ____.
_______ _____ ____ ___ ___ ________ _______.
_____ ____ _________ ______ ____ _____ ____ _________ _____ ____ _____.
_________ _____ ________ ____ __________ ___ _____.
_________ _________ _____ _______ ________ _____ ________.
____ ____ _________ __________ __________ ____ ______ ___ _______ ________ _____.
_________ _________ _____ __________ ___ __________ _________.
______ ________ ______ _________ _______.
______ _____ ____ ______ __________ __________ _______ ______.
__________ ______ _____ ___ __________.
___ ______ ______ _____ _____ __________ ___ _______ _______ ________ __________.
______ ________ ___ ________ ___ ______ _____ ____ ________ ____ __________ __________.
_______ ____ _____ __________ ______ ____ _________.
___ ___ ____ _____ _______.
_______ ____ _____ _____ _______ ________ _____ ________ ______.
___ _______ _______ __________ _________.
______ _________ ______ ___ _____ _____ ________ ____ ______ _________.
_______ ________ ___ ______ _____ __________ _______ ________ __________ _________ _____.
_________ ________ ________ ______ __________ _______ __________.
___ ______ _______ ___ ____ ______.
_______ ____ __________ ______ ____ _____ _____.
___ _______ _________ _____ ______ ____ ________ ____ ________ _________ ________ ____.
____ _______ _____ __________ _________ _______ __________ ________ _________ _____ _________ _______.
________ ___ __________ _______ _____ ____ __________ ________.
Get Full Answer on WhatsApp