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 / rashmi sharma

#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 ?    85 Yes 41 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

#define PRINT(int) printf("int = %d ",int) main() {< BR> intx,y,z; x=03;y=02;z=01; PRINT(x^x); z<<=3;PRINT(x); y>>=3;PRINT(y); }

734


Are there namespaces in c?

578


What is #include called?

581


What is return in c programming?

523


What is the meaning of c in c language?

608






Is array a primitive data type in c?

589


What are dangling pointers in c?

654


What is a buffer in c?

584


Write a C program to count the number of email on text

1426


How is a macro different from a function?

663


What is the use of header?

632


Is it possible to pass an entire structure to functions?

565


Explain what will be the outcome of the following conditional statement if the value of variable s is 10?

756


What is a program flowchart and explain how does it help in writing a program?

692


What are the restrictions of a modulus operator?

645