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

#include<stdio.h>

main ()
{
int num, a, b,c,d,e, sum;

printf ("Enter the five digit number : ");
scanf ("%d", &num);
e = num % 10;
d = (num / 10)% 10;
c = (num / 100)% 10;
b = (num / 1000)% 10;
a = (num / 10000)% 10;
sum= a+b+c+d+e;
printf ("The sum of the digits is: %d", sum);

}

Is This Answer Correct ?    25 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain how can you avoid including a header more than once?

1093


Is python a c language?

1015


Explain the advantages of using macro in c language?

1003


What is use of integral promotions in c?

1150


What is wrong with this program statement? void = 10;

1257


What are the advantages of c language?

1099


How can I write data files which can be read on other machines with different word size, byte order, or floating point formats?

1035


Can we assign string to char pointer?

1113


What are the complete rules for header file searching?

1091


What are variables and it what way is it different from constants?

1244


What is the maximum no. of arguments that can be given in a command line in C.?

1154


Can you define which header file to include at compile time?

1022


What is getch () for?

1240


Write a code to generate divisors of an integer?

1071


Explain what does a function declared as pascal do differently?

1292