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
How do you generate random numbers in C?
What is a function in c?
Given below are three different ways to print the character for ASCII code 88. Which is the correct way1) char c = 88; cout << c << " ";2) cout.put(88);3) cout << char(88) << " "; a) 1 b) 2 c) 3 d) constant
What is difference between main and void main?
What is the use of pragma in embedded c?
What is a program flowchart and how does it help in writing a program?
what is the difference between 123 and 0123 in c?
Explain the process of converting a Tree into a Binary Tree.
What's the right way to use errno?
Write a program to print numbers from 1 to 100 without using loop in c?
Are local variables initialized to zero by default in c?
What is pre-emptive data structure and explain it with example?
How can I read a binary data file properly?
What is the total generic pointer type?
Explain the priority queues?