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
Can we change the value of constant variable in c?
What does the function toupper() do?
Can include files be nested?
Is main an identifier in c?
What is a null pointer assignment error? What are bus errors, memory faults, and core dumps?
How can you return multiple values from a function?
What are pointers in C? Give an example where to illustrate their significance.
What library is sizeof in c?
What are high level languages like C and FORTRAN also known as?
the question is that what you have been doing all these periods (one year gap)
What are 3 types of structures?
what is the c source code for the below output? 10 10 10 10 10 10 10 10 10 10 9 9 7 6 6 6 6 6 6 9 7 5 9 7 3 2 2 5 9 7 3 1 5 9 7 3 5 9 7 4 4 4 4 5 9 7 8 8 8 8 8 8 8 8 9
How do you print only part of a string?
Why does notstrcat(string, "!");Work?
what type of questions arrive in interview over c programming?