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

#include<stdio.h>
#include<math.h>
#include<conio.h>
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 ?    11 Yes 20 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What do you mean by command line argument?

1115


write a program that types this pattern: 12345678987654321 12345678 87654321 1234567 7654321 123456 654321 12345 54321 1234 4321 123 321 12 21 1 1

3875


Differentiate between declaring a variable and defining a variable?

1003


What is pivot in c?

990


What is the use of parallelize in spark?

997


What is the difference between functions abs() and fabs()?

1112


In c programming language, how many parameters can be passed to a function ?

1072


What do you mean by keywords in c?

1099


What is array of structure in c programming?

1256


Define recursion in c.

1218


What are unions in c?

996


Explain how can I right-justify a string?

1012


Which driver is a pure java driver

1549


Why C language is a procedural language?

990


When should the volatile modifier be used?

1123