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

Explain what are binary trees?

1021


What is meant by type casting?

1020


Explain what are the different file extensions involved when programming in c?

1052


What is an example of structure?

981


What does c mean before a date?

1104


What does 3 periods mean in texting?

1012


Explain how do you print an address?

1087


How does #define work?

1011


code for find determinent of amatrix

1917


Write a program to print all permutations of a given string.

1127


How are strings stored in c?

972


How many levels of pointers can you have?

1135


Which operators cannot be overloaded a) Sizeof b) .* c) :: d) all of the above

1095


Why c is called object oriented language?

1007


What is %g in c?

1019