#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