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
What do you mean by command line argument?
write a program that types this pattern: 12345678987654321 12345678 87654321 1234567 7654321 123456 654321 12345 54321 1234 4321 123 321 12 21 1 1
Differentiate between declaring a variable and defining a variable?
What is pivot in c?
What is the use of parallelize in spark?
What is the difference between functions abs() and fabs()?
In c programming language, how many parameters can be passed to a function ?
What do you mean by keywords in c?
What is array of structure in c programming?
Define recursion in c.
What are unions in c?
Explain how can I right-justify a string?
Which driver is a pure java driver
Why C language is a procedural language?
When should the volatile modifier be used?