Answer Posted / keerthireddy
#include<stdio.h>
#include<conio.h>
main()
{
int n,i,sum=0,r;
printf("enter the value");
scanf("%d",&n);
while(n>0)
{
r=n%10;
sum=sum+r;
n=n/10;
}
printf("sum = %d",sum);
}
output:
3456
how it works as follows:
3456%10 means it gives reminder as 6
6 will be added to the sum
3456/10 means it gives quotient as 345
then again loop is executing until the n value is 0
finally the result as 6+5+4+3=18
| Is This Answer Correct ? | 9 Yes | 1 No |
Post New Answer View All Answers
Input is "rama loves rajesh and rajesh Loves rama also and rajesh wear gloves and bloves" To print output is count the numbers of times repeted the word love without case sensitive.
Who developed c language?
What is use of bit field?
What is function prototype in c language?
Explain c preprocessor?
a program that can input number of records and can view it again the record
What are data structures in c and how to use them?
What is the meaning of && in c?
Can math operations be performed on a void pointer?
a parameter passed between a calling program and a called program a) variable b) constant c) argument d) all of the above
Where static variables are stored in memory in c?
Differentiate between ordinary variable and pointer in c.
What is bubble sort in c?
How can I automatically locate a programs configuration files in the same directory as the executable?
What are the differences between new and malloc in C?