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
the 'sizeof' operator reported a larger size than the calculated size for a structure type. What could be the reason?
What is extern variable in c with example?
Explain do array subscripts always start with zero?
can any one tel me wt is the question pattern for NIC exam
What is the purpose of scanf() and printf() functions?
I need previous papers of CSC.......plz help out by posting them.......
What is assert and when would I use it?
What are the three constants used in c?
A function can make the value of a variable available to another by a) declaring the variable as global variable b) Passing the variable as a parameter to the second function c) Either of the two methods in (A) and (B) d) binary stream
What’s the special use of UNIONS?
What is a pointer on a pointer in c programming language?
What is difference between class and structure?
Is it better to use a pointer to navigate an array of values, or is it better to use a subscripted array name?
Write a factorial program using C.
When was c language developed?