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 / sriharsha
void main()
{
long int num;
int sum=0,temp;
clrscr();
printf("Enter the numbe\n");
scanf("%ld",&num);
while(num!=0)
{
temp=num%10;
sum=sum+temp;
num=num/10;
}
printf("%d",sum);
getch();
}
| Is This Answer Correct ? | 111 Yes | 42 No |
Post New Answer View All Answers
Why is it that not all header files are declared in every C program?
Explain data types & how many data types supported by c?
What is structure data type in c?
Why c is a procedural language?
Is c# a good language?
what is different between auto and local static? why should we use local static?
What is a class c rental property?
How many identifiers are there in c?
What is selection sort in c?
What is structure packing in c?
.find the output of the following program? char*myfunc(char*ptr) { ptr +=3; return (ptr); } int main() { char*x,*y; x="HELLO"; y=myfunc(x); printf("y = %s ",y); return 0; }
What are categories used for in c?
a function gets called when the function name is followed by a a) semicolon (;) b) period(.) c) ! d) none of the above
What is wrong with this program statement? void = 10;
Explain how do you list a file’s date and time?