Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

write a program to sum of its digit with using control
structure or with out using loop. for ex: let the number is
25634 then answer will be=2+5+6+3+4=20

Answer Posted / lalabs

// assume that num is non-negative.

int sum_digits_recursive ( int num )
{
if ( num == 0 ) return 0;
return (num % 10 + sum_digits_recursive ( num / 10 ));
}

Is This Answer Correct ?    6 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is sizeof array?

1061


List the variables are used for writing doubly linked list program.

2036


write an algorithm to display a square matrix.

2714


Tell me what are bitwise shift operators?

1133


c language interview questions & answer

1966


What is %lu in c?

1262


What is time complexity c?

1001


What is indirection in c?

1076


When should a far pointer be used?

1137


What is void main ()?

1078


Explain how do you determine whether to use a stream function or a low-level function?

1093


Is main is user defined function?

1156


How do I read the arrow keys? What about function keys?

1088


How do we open a binary file in Read/Write mode in C?

1242


write a program that reads lines(using getline), converts each line to an integer using atoi, and computes the average of all the numbers read. also compute the standard deviation.

2532