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 / rama krishna sidhartha

#include <stdio.h>
#include<conio.h>
void main()
{
int s=0,c,n;
clrscr();
printf("\n ENTER A VALUE : ");
scanf("%d",&n);
while(n>0)
{
c=n%10;
s=s+c;
n=n/10;
}
printf("\n THE SUM OF INDIVIDUAL DIGITS : %d",s);
getch();
}

Is This Answer Correct ?    10 Yes 10 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a far pointer in c?

778


What are pointers in C? Give an example where to illustrate their significance.

956


What is the difference between ‘g’ and “g” in C?

3400


Explain the advantages and disadvantages of macros.

833


What is a pointer in c?

958


What is the use of bit field?

870


What is the use of header files?

811


What are the 32 keywords in c?

844


What is pointer & why it is used?

794


Why isnt any of this standardized in c?

829


Is it cc or c in a letter?

755


write a programe to accept any two number and check the following condition using goto state ment.if a>b,print a & find whether it is even or odd and then print.and a

1650


Do you know what are the properties of union in c?

778


What are the types of macro formats?

798


can we have joblib in a proc ?

1920