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 / md osama

#include<stdio.h>
#include<conio.h>
void main()
{
int d1,d2,d3,d4,d5,sum;
long num;
clrscr();
printf("enter the five digit number:");
scanf("%ld",&num);
d1=(num%10);
d2=(num%100-num%10)/10;
d3=(num%1000-num%100)/100;
d4=(num%10000-num%1000)/1000;
d5=(num-num%10000)/10000;
sum=d1+d2+d3+d4+d5;
printf("\n the sum of the digit is:%d",sum);
}

Is This Answer Correct ?    12 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

the question is that what you have been doing all these periods (one year gap)

2140


What are disadvantages of C language.

1222


Is it better to use a macro or a function?

1206


Write a program to generate random numbers in c?

1156


How do I round numbers?

1054


Explain built-in function?

1188


What is indirection in c?

1116


What happens if a header file is included twice?

1078


Does c have enums?

1175


Why do we use header files in c?

1125


What is the difference between the expression “++a” and “a++”?

1275


Is the exit() function same as the return statement? Explain.

1157


What is the use of putchar function?

1109


about c language

2074


What is pointer to pointer in c with example?

1158