Subscribe for more such posts..

Dear Reader...
I hope u are like my posts. If so then please don't forget to like , share and follow my blog for more such posts ,also feel free to write suggestions in the comment box given over here.

Thank you...

Search This Blog

C program to find the sum of digits of a 5 digit number using recursion.

#include <stdio.h>
int fun(int n)
{
	int i = n % 10 ;
	if (n!=0)
	return i + fun(n/10);
	else 
	return 0 ;
}
int main()
{
	int num;
	printf("Enter any number to find sum of digits: ");
	scanf("%d" , &num);
	printf("Sum of digits of %d = %d" , num , fun(num));
	
	return 0 ; 
}



No comments:

Post a Comment