Answers for "sum of digits in c++ using recursion"

0

sum of digits in c++ using recursion

// Recursive C++ program to find sum of digits(int)
#include <iostream>
using namespace std; 
// Function to check sum of digit using recursion
int sum_of_digit(int n)
{
    if (n == 0)
    return 0;
    return (n % 10 + sum_of_digit(n / 10));
}
int main(){
    cout <<sum_of_digit(1234)<< endl;
    return 0;
}
Posted by: Guest on October-15-2021

Code answers related to "sum of digits in c++ using recursion"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language