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 / nishant rai
#include<stdio.h>
#include<conio.h>
void main()
{
int num=0,sum=0,k=0;
pirntf("enter the number\n");
scanf("%d",num);
while(num!=0);
{
k=num%10;
sum=sum+k;
num=num/10;
}
printf("%d",sum);
getch();
}
| Is This Answer Correct ? | 13 Yes | 14 No |
Post New Answer View All Answers
What is the difference between char array and char pointer?
Explain what is wrong with this program statement?
How can I open a file so that other programs can update it at the same time?
write a program to find out prime number using sieve case?
What are the modifiers available in c programming language?
Differentiate between functions getch() and getche().
What is the difference between local variable and global variable in c?
Explain how can a program be made to print the name of a source file where an error occurs?
How do you convert strings to numbers in C?
What's the total generic pointer type?
What are the differences between new and malloc in C?
I need a help with a program: Write a C program that uses data input in determining the whole of points A and a whole of circles B. Find two points in A so that the line which passes through them, cut through the maximum number of circles.
What are types of functions?
What the different types of arrays in c?
a function gets called when the function name is followed by a a) semicolon (;) b) period(.) c) ! d) none of the above