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
What is a 'null pointer assignment' error?
List the variables are used for writing doubly linked list program.
how logic is used
my project name is adulteration of chille powder.how can i explain it to the hr when he asks me about the project?
Is there a way to switch on strings?
can anyone suggest some site name..where i can get some good data structure puzzles???
What is strcmp in c?
How will you delete a node in DLL?
How can I remove the leading spaces from a string?
Is struct oop?
How can you determine the maximum value that a numeric variable can hold?
Write an algorithm for implementing insertion and deletion operations in a singly linked list using arrays ?
What are the loops in c?
Explain bit masking in c?
Explain #pragma statements.