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

Is c dynamically typed?

659


What is difference between structure and union?

588


Explain what are the different file extensions involved when programming in c?

625


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"

1574


Explain the Difference between the New and Malloc keyword.

674






What is the explanation for the dangling pointer in c?

664


What is binary tree in c?

617


What is wrong in this statement?

595


Which is the memory area not included in C program? give the reason

1491


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

631


Explain the use of bit fieild.

700


List some applications of c programming language?

537


Write a program to generate the Fibinocci Series

650


What does the error message "DGROUP exceeds 64K" mean?

718


show how link list can be used to repersent the following polynomial i) 5x+2

1667