Question: Write a recursive function, sumDigits, that takes an integer as a parameter and returns the sum of the digits of the integer. functions.cpp #include using
Write a recursive function, sumDigits, that takes an integer as a parameter and returns the sum of the digits of the integer.
functions.cpp
#include
using namespace std;
inline void sumDigits(long long& sum, long long num) { // write your recursive sum function here }
main.cpp
#include
using namespace std;
int main() { long long num = 930567829100185; long long sum = 0;
sumDigits(sum, num);
cout << "The sum of the digits of " << num << " is: " << sum << endl;
return 0; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
