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

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 ?    111 Yes 42 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is use of integral promotions in c?

1207


What is bash c?

1065


What is data type long in c?

1116


What is the difference between volatile and const volatile?

1049


What are types of functions?

1080


What do mean by network ?

1216


What are the different types of errors?

1208


Q.1 write a program to create binary tree 1 to 16 numbers? Q.2 write a program to creat a binary search tree for the member that is given by user?

2597


what is stack , heap ,code segment,and data segment

2770


Why does this code crash?

1144


how can i write a program that prints out a box such that whenever i press any key8(coordinate number) on the keyboard, the box moves.

1737


Explain what does the characters 'r' and 'w' mean when writing programs that will make use of files?

1310


Explain what are multidimensional arrays?

1122


Why is it usually a bad idea to use gets()? Suggest a workaround.

1871


Explain the difference between getch() and getche() in c?

1051