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 indirection? How many levels of pointers can you have?
Explain built-in function?
What are register variables? What are the advantage of using register variables?
Where in memory are my variables stored?
How can I find the modification date and time of a file?
I need a sort of an approximate strcmp routine?
In this problem you are to write a program that will cut some number of prime numbers from the list of prime numbers between 1 and N.Your program will read in a number N; determine the list of prime numbers between 1 and N; and print the C*2 prime numbers from the center of the list if there are an even number of prime numbers or (C*2)-1 prime numbers from the center of the list if there are an odd number of prime numbers in the list.
Explain how do you list a file’s date and time?
What are high level languages like C and FORTRAN also known as?
What is the basic structure of c?
Why c is faster than c++?
What is else if ladder?
Explain about block scope in c?
What is assert and when would I use it?
Why do we use header files in c?