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

What is the difference between struct and typedef struct in c?

1123


while initialization of array why we use a[][2] why not a[2][]...?

2355


How can I find the modification date of a file?

1278


which of the following shows the correct hierarchy of arithmetic operations in C a) (), **, * or/,+ or - b) (),**,*,/,+,- c) (),**,/,*,+,- d) (),/ or *,- or +

1729


What are header files and what are its uses in C programming?

1228


Tell us two differences between new () and malloc ()?

1183


What is character constants?

1178


Add Two Numbers Without Using the Addition Operator

820


What is FIFO?

1698


When should volatile modifier be used?

1010


What header files do I need in order to define the standard library functions I use?

1053


How can I find the modification date and time of a file?

1082


Give basis knowledge of web designing ...

2016


What is volatile keyword in c?

1034


What are structural members?

1006