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 / synner
#include<stdio.h>
#include<math.h>
#include<conio.h>
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 ? | 11 Yes | 20 No |
Post New Answer View All Answers
in multiple branching construct "default" case is a) optional b) compulsarily c) it is not include in this construct d) none of the above
illustrate the use of address operator and dereferencing operator with the help of a program guys plzzz help for this question
Differentiate between new and malloc(), delete and free() ?
Describe how arrays can be passed to a user defined function
Which header file is essential for using strcmp function?
How can you increase the size of a dynamically allocated array?
What is the meaning of && in c?
What is static function in c?
Explain how can I read and write comma-delimited text?
What tq means in chat?
Are the variables argc and argv are local to main?
Explain output of printf("Hello World"-'A'+'B'); ?
Describe newline escape sequence with a sample program?
What oops means?
Why c language is called c?