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 / thiruapthi rao

// mainlogic
while(number>0)
{
remainder=number%10;
sum=sum+remainder;
number=number/10;
}
/*
number=123
sum=1+2+3=6
*/

Is This Answer Correct ?    0 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

4. main() { int c=- -2; printf("c=%d",c); }

1371


What is function prototype in c with example?

580


Explain why can’t constant values be used to define an array’s initial size?

857


What are the __date__ and __time__ preprocessor commands?

574


By using C language input a date into it and if it is right?

575






Who developed c language?

643


What are the back slash character constants or escape sequence charactersavailable in c?

686


What are variables and it what way is it different from constants?

787


How can I find out how much free space is available on disk?

631


Why structure is used in c?

597


State the difference between realloc and free.

636


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

1520


a value that does not change during program execution a) variabe b) argument c) parameter d) none

698


What does %p mean?

596


Is c object oriented?

543