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 / jegadeesh
#include<stdio.h>
void main()
{
int i,j;
scanf("%d",&i);
if((i%9)==0)
printf("The sum of digit is 9");
else
{
j=i%9;
printf("%d",j);
}
}
//the above will print result as 6 if given as 12345 since
1+2+3+4+5=15 and proceeding 1+5 we get as 6.....
is this an apt answer...
Is This Answer Correct ? | 11 Yes | 36 No |
Post New Answer View All Answers
Why is structure padding done in c?
What is a constant and types of constants in c?
Why does this code crash?
Is file a keyword in c?
What do you mean by c what are the main characteristics of c language?
c program for searching a student details among 10 student details
int main() { Int n=20,i; For(i=0;i<=n;i--) { Printf(“-“); Return 0;
What is the usage of the pointer in c?
List some basic data types in c?
what is diffrence between linear and binary search in array respect to operators?what kind of operator can be used in both seach methods?
What is the value of c?
Differentiate between #include<...> and #include '...'
What is difference between structure and union with example?
How can I pad a string to a known length?
What are the advantage of c language?