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 / areeb ahmed khan

#include<stdio.h>
#include<conio.h>
main()
{
int a,b,c,d,e;
int digit,number,sum;

printf("\n\n\n");

printf("Enter a five-digit number :");
scanf("%d",&number);

digit=number%10;
a=digit;

number=number/10;
digit=number%10;
b=digit;

number=number/10;
digit=number%10;
c=digit;

number=number/10;
digit=number%10;
d=digit;

number=number/10;
digit=number%10;
e=digit;

sum=a+b+c+d+e;
printf("\nThe sum of five-digit number is : %d",sum);

getch();
}

Is This Answer Correct ?    7 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Do you have any idea about the use of "auto" keyword?

1079


Explain what is the benefit of using const for declaring constants?

1025


What is the difference between volatile and const volatile?

983


Why enum is used in c?

949


What is array of structure in c programming?

1286


A global variable when referred to in another file is declared as this a) local variable b) external variable c) constant d) pointers

1190


What is header file in c?

1063


Explain what is wrong with this program statement?

1117


Differentiate abs() function from fabs() function.

1007


What is the meaning of && in c?

1013


Are the variables argc and argv are always local to main?

1020


Why c is known as a mother language?

1079


What is variable initialization and why is it important?

1247


Explain how do you determine whether to use a stream function or a low-level function?

1076


What is the use of #define preprocessor in c?

1069