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

how do you execute a c program in unix.

1156


Define Array of pointers.

1154


How can I automatically locate a programs configuration files in the same directory as the executable?

1231


What are the 5 elements of structure?

1128


What is array of structure in c?

1252


What is c system32 taskhostw exe?

1071


why to assign a pointer to null sometimes??how can a pointer we declare get assigned with a garbage value by default???

2024


write a program to generate address labels using structures?

4622


HOW TO SOLVE A NUMERICAL OF LRU IN OS ??????

2746


How can I determine whether a machines byte order is big-endian or little-endian?

1124


Explain how can type-insensitive macros be created?

1042


Does c have class?

1179


What are the types of data structures in c?

1210


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

1070


Explain the use of fflush() function?

1132