Q8 A 5-digit positive integer is entered through the keyboard, write a recursive and a non-recursive function to calculate sum of digits of the 5-digit number.
Program: 129
A 5-digit positive integer is entered through the keyboard, write a recursive and a non-recursive function to calculate sum of digits of the 5-digit number.
How to use recursion and non recursion function to get sum of a positive integer digit.
Output:
Enter an integer: 12345 Calculate sum using recursion: 15 Calculate sum without recursion: 15