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

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

615


Explain what is the difference between null and nul?

646


Which is better oop or procedural?

619


Why clrscr is used in c?

573


Write a program to display all the prime nos from 1 to 1000000, your code should not take time more than a minute to display all the nos.

1587






What is the difference between declaring a variable and defining a variable?

710


What is a void pointer? When is a void pointer used?

614


What is || operator and how does it function in a program?

620


What is structure of c program?

597


What is the c language function prototype?

639


code for replace tabs with equivalent number of blanks

1629


Explain output of printf("Hello World"-'A'+'B'); ?

967


How can you find the exact size of a data type in c?

591


What does sizeof return c?

592


write a program to convert a expression in polish notation(postfix) to inline(normal) something like make 723+* (2+3) x 7 (not sure) just check out its mainly printing expression in postfix form to infix.

3494