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 / pavan kumar

#include<stdio.h>
int main()
{
int a=0,b=0,c=0,d=0,e=0,f=0,g=0,h=0,sum;
printf("Enter the five digit number:");
scanf("%d",&sum);
a=sum%10;
b=sum/10;
c=b%10;
d=b/10;
e=d%10;
f=d/10;
g=f%10;
h=f/10;
printf("sum of the digits:%d",a+c+e+g+h);
}

Is This Answer Correct ?    7 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do you do dynamic memory allocation in C applications?

1045


What is s or c?

1014


Difference between Function to pointer and pointer to function

1019


Why void main is used in c?

999


What is the usage of the pointer in c?

1043


int i=3; this declaration tells the C compiler to a) reserve space in memory to hold the integer value b) associate the name i with this memory location c) store the value 3 at this location d) all the above

1222


What are register variables in c?

975


What is variable in c example?

993


can we change the default calling convention in c if yes than how.........?

2471


How does selection sort work in c?

984


What is the auto keyword good for?

1065


Explain is it better to use a pointer to navigate an array of values, or is it better to use a subscripted array name?

1155


How many levels deep can include files be nested?

1099


What are the main characteristics of c language describe the structure of ac program?

1149


What is the use of f in c?

934