C languageC SolutionChapter 6Programming

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

Lokesh Kumar

Being EASTER SCIENCE's founder, Lokesh Kumar wants to share his knowledge and ideas. His motive is "We assist you to choose the best", He believes in different thinking.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.