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
Write a program to compute the similarity between two strings - The program should get the two strings as input - Then it will output one single number which is the percentage of similarity between the two strings
Which of the following operators is incorrect and why? ( >=, <=, <>, ==)
What is bss in c?
What is ctrl c called?
can anyone suggest some site name..where i can get some good data structure puzzles???
will u please send me the placement papers to my mail???????????????????
Is return a keyword in c?
How can I find out how much free space is available on disk?
Tell us the use of fflush() function in c language?
What does & mean in scanf?
Is c is a high level language?
What is wrong with this statement? Myname = 'robin';
Can two or more operators such as and be combined in a single line of program code?
Why is c still so popular?
How are variables declared in c?