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 nested structure?

1058


Can I initialize unions?

1053


Here is a neat trick for checking whether two strings are equal

1030


What is the difference between class and object in c?

1188


Which node is more powerful and can handle local information processing or graphics processing?

1332


What is a far pointer in c?

1053


What is meant by int main ()?

1218


What are the advantages of using macro in c language?

1145


Which type of language is c?

1086


What could possibly be the problem if a valid function name such as tolower() is being reported by the C compiler as undefined?

1291


Describe the order of precedence with regards to operators in C.

1051


if a is an integer variable, a=5/2; will return a value a) 2.5 b) 3 c) 2 d) 0

1961


Write a C/C++ program to add a user to MySQL. The user should be permitted to only "INSERT" into the given database.

1983


What are lookup tables in c?

1010


what is event driven software and what is procedural driven software?

2591