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

In C, What is the #line used for?

2187


What is the explanation for cyclic nature of data types in c?

1192


What is gets() function?

1113


a c variable cannot start with a) an alphabet b) a number c) a special symbol d) both b and c above

1214


What is the difference between NULL and NUL?

1278


Why void is used in c?

1004


write a c program to print the next of a particular no without using the arithmetic operator or looping statements?

3927


Given only putchar (no sprintf, itoa, etc.) write a routine putlong that prints out an unsigned long in decimal. [ I gave the obvious solution of taking % 10 and / 10, which gives us the decimal value in reverse order. This requires an array since we need to print it out in the correct order. The interviewer wasn't too pleased and asked me to give a solution which didn't need the array ].

1079


What is indirection? How many levels of pointers can you have?

1117


How does struct work in c?

1062


Why can't I perform arithmetic on a void* pointer?

1086


Explain how can I convert a number to a string?

1143


In which layer of the network datastructure format change is done

1875


Tell me what is the purpose of 'register' keyword in c language?

993


What is the difference between single charater constant and string constant?

1074