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 / jegadeesh

#include<stdio.h>
void main()
{
int i,j;
scanf("%d",&i);
if((i%9)==0)
printf("The sum of digit is 9");
else
{
j=i%9;
printf("%d",j);
}
}

//the above will print result as 6 if given as 12345 since
1+2+3+4+5=15 and proceeding 1+5 we get as 6.....
is this an apt answer...

Is This Answer Correct ?    11 Yes 36 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a 'null pointer assignment' error?

1252


List the variables are used for writing doubly linked list program.

2084


how logic is used

2023


my project name is adulteration of chille powder.how can i explain it to the hr when he asks me about the project?

1646


Is there a way to switch on strings?

1129


can anyone suggest some site name..where i can get some good data structure puzzles???

2159


What is strcmp in c?

1217


How will you delete a node in DLL?

1338


How can I remove the leading spaces from a string?

1213


Is struct oop?

1061


How can you determine the maximum value that a numeric variable can hold?

1299


Write an algorithm for implementing insertion and deletion operations in a singly linked list using arrays ?

3566


What are the loops in c?

1052


Explain bit masking in c?

1193


Explain #pragma statements.

1100