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
#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); }
Are there namespaces in c?
What is #include called?
What is return in c programming?
What is the meaning of c in c language?
Is array a primitive data type in c?
What are dangling pointers in c?
What is a buffer in c?
Write a C program to count the number of email on text
How is a macro different from a function?
What is the use of header?
Is it possible to pass an entire structure to functions?
Explain what will be the outcome of the following conditional statement if the value of variable s is 10?
What is a program flowchart and explain how does it help in writing a program?
What are the restrictions of a modulus operator?