Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

Is it possible to pass an entire structure to functions?

942


Explain how do I determine whether a character is numeric, alphabetic, and so on?

1079


How can I write a function analogous to scanf?

1099


Difference between pass by reference and pass by value?

1097


What are global variables and explain how do you declare them?

1031


Write a program on swapping (100, 50)

1063


Function which gives a pointer to a binary trees const an integer value at each code, return function of all the nodes in binary tree.?

1014


Which type of language is c?

1020


What is a built-in function in C?

1514


the statement while(i) puts the entire logic in loop. this loop is called a) indefinite loop b) definite loop c) loop syntax wrong d) none of the above

990


What is const and volatile in c?

989


What does the error message "DGROUP exceeds 64K" mean?

1169


Why is event driven programming or procedural programming, better within specific scenario?

2366


What is c basic?

1125


I heard that you have to include stdio.h before calling printf. Why?

1007