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)
{
if((i%9)==0)
printf("The sum of digit is 9");
else
{
j=i%9;
printf("%d",j);
}
}
else
{
printf("The sum of digit is ",i);
}
}
//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 answer u are looking...
| Is This Answer Correct ? | 9 Yes | 4 No |
Post New Answer View All Answers
Write a c program to build a heap method using Pointer to function and pointer to structure ?
What is this infamous null pointer, anyway?
how to print the character with maximum occurence and print that number of occurence too in a string given ?
How can you increase the allowable number of simultaneously open files?
How do I get a null pointer in my programs?
How #define works?
What is the auto keyword good for?
What is p in text message?
What is indirection?
Explain what is the difference between functions getch() and getche()?
Describe the complexity of Binary search, Quicksort and various other sorting and searching techniques..
In C, What is the #line used for?
What is %lu in c?
Write a function stroverlap that takes (at least) two strings, and concatenates them, but does not duplicate any overlap. You only need to worry about overlaps between the end of the first string and the beginning of the second string. Examples: batman, manonthemoon = batmanonthemoon batmmamaman, mamamanonthemoon = batmmamamanonthemoon bat, man = batman batman, batman = batman batman, menonthemoon = batmanmenonthemoon
How many keywords (reserve words) are in c?