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

Explain how can I remove the trailing spaces from a string?

1011


Why doesn't C support function overloading?

2646


Why do we use return in c?

958


When I tried to go into a security sites I am denied access and a message appeared saying 'applet not initialize'. How can I rectify this problem.

1946


What are the types of bitwise operator?

1063


What is meant by errors and debugging?

1069


How many parameters should a function have?

1139


Explain what are linked list?

1005


What is static volatile in c?

989


What is a macro in c preprocessor?

1068


What does nil mean in c?

1195


Is c call by value?

976


What is this infamous null pointer, anyway?

999


Explain what is the difference between the expression '++a' and 'a++'?

1170


How do I swap bytes?

1030