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
Is c dynamically typed?
What is difference between structure and union?
Explain what are the different file extensions involved when programming in c?
Hello. How to write a C program to check and display president party like if i type in the console "biden" and hit enter the output shoud be : "biden is democrat" and if i type "trump" and hit enter the output shoud be: "trump is republican"
Explain the Difference between the New and Malloc keyword.
What is the explanation for the dangling pointer in c?
What is binary tree in c?
What is wrong in this statement?
Which is the memory area not included in C program? give the reason
the number of measuring units from a arbitrary starting point in a record area or control block to some other point a) branching b) recording pointer c) none d) offset
Explain the use of bit fieild.
List some applications of c programming language?
Write a program to generate the Fibinocci Series
What does the error message "DGROUP exceeds 64K" mean?
show how link list can be used to repersent the following polynomial i) 5x+2