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 / saurabh vyas
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);
}
| Is This Answer Correct ? | 4 Yes | 9 No |
Post New Answer View All Answers
Is struct oop?
write a program that reads lines(using getline), converts each line to an integer using atoi, and computes the average of all the numbers read. also compute the standard deviation.
What are the parts of c program?
What does *p++ do? What does it point to?
Explain how do you use a pointer to a function?
What is a macro?
Why n++ execute faster than n+1 ?
general for is %wd,f-d; in this system "w" means a) 'w' represent total width of digits b) 'w' represent width which includes the digits before,after decimal place and the decimal point c) 'w' represent width which includes the digits before only d) 'w' represent width after decimal place only
write a program to display all prime numbers
Tell me with an example the self-referential structure?
What is a class c rental property?
What is property type c?
What is the equivalent code of the following statement in WHILE LOOP format?
What are the 5 data types?
what does static variable mean?