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

Define C in your own Language.

645


What is operator promotion?

635


What are volatile variables in c?

529


Explain how can I make sure that my program is the only one accessing a file?

635


how to introdu5ce my self in serco

1529






Explain how to reverse singly link list.

616


When should you use a type cast?

595


write a program to print data of 5 five students with structures?

1612


What is a good way to implement complex numbers in c?

600


what is stack , heap ,code segment,and data segment

2227


How can I implement sets or arrays of bits?

611


How can you find the day of the week given the date?

623


Can a pointer be volatile in c?

539


hi... can anyone help me to make a two-dimensinal arrays in finding the sum of two elements plzzz. thnx a lot...

1451


Explain how are portions of a program disabled in demo versions?

659