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
What is use of integral promotions in c?
What is bash c?
What is data type long in c?
What is the difference between volatile and const volatile?
What are types of functions?
What do mean by network ?
What are the different types of errors?
Q.1 write a program to create binary tree 1 to 16 numbers? Q.2 write a program to creat a binary search tree for the member that is given by user?
what is stack , heap ,code segment,and data segment
Why does this code crash?
how can i write a program that prints out a box such that whenever i press any key8(coordinate number) on the keyboard, the box moves.
Explain what does the characters 'r' and 'w' mean when writing programs that will make use of files?
Explain what are multidimensional arrays?
Why is it usually a bad idea to use gets()? Suggest a workaround.
Explain the difference between getch() and getche() in c?