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

#include<stdio.h>
int main()
{
int n,d1,d2,d3,d4,d5,s;
printf("enter a five digit no");
scanf("%d",&n);
d5=n%10;n=n/10;
d4=n%10;n=n/10;
d3=n%10;n=n/10;
d2=n%10;n=n/10;
d1=n%10;
s=d1+d2+d3+d4+d5;
return 0;
}

Is This Answer Correct ?    29 Yes 13 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Describe the order of precedence with regards to operators in C.

1100


How can I read/write structures from/to data files?

1012


Can you please explain the difference between malloc() and calloc() function?

1174


Explain what are multidimensional arrays?

1120


What are pointers?

1156


Explain what is the difference between far and near ?

1162


How many keywords are there in c?

1120


What is static volatile in c?

1073


What is the general form of #line preprocessor?

1039


What do you mean by dynamic memory allocation in c?

1148


write a c program to print the next of a particular no without using the arithmetic operator or looping statements?

4041


How reliable are floating-point comparisons?

1140


pierrot's divisor program using c or c++ code

2282


What is action and transformation in spark?

1225


How are pointers declared in c?

1111