if a five digit number is input through the keyboard, write
a program to calculate the sum of its digits.
(hint:-use the modulus operator.'%')

Answer Posted / amit amar mahesh bhava

#include<sthio.h>
#include<conio.h>
void main()
{
int a,b,c,d,e,f,g,h,i,j,k,l;
printf("enter a five digit number");
scanf("%d",&a);
b=a%10;
c=a/10;
d=c%10;
e=c/10;
f=e%10;
g=e/10;
h=g%10;
i=g/10;
j=i%10;
k=i/10;
l=b+d+f+h+j;
printf("sum of the digit=%d",l);
getch();
}

Is This Answer Correct ?    7 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How we can insert comments in a c program?

623


Define Array of pointers.

629


What are the application of c?

637


What is mean by Data Driven framework in QTP? Can any one answer me in details on this regard.

1779


What is a stream water?

648






List the difference between a "copy constructor" and a "assignment operator"?

576


C program execution always begins with a) #include b) comment (/*-------*/) c) main() d) declaration instructions

606


FILE PROGRAMMING

1773


What is the argument of a function in c?

567


Is c++ based on c?

644


how logic is used

1493


Explain the advantages of using macro in c language?

570


Explain modulus operator. What are the restrictions of a modulus operator?

595


Is there any demerits of using pointer?

620


What does calloc stand for?

643