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 / aha na

#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,sum=0;
clrscr();
printf("\n enter a number",i);
scanf("%d",&i);

while(i<=0)
{
j=i%10;
sum=sum+j;
i=i/10;
}
printf("\n the sum of the digits
are:%d\n");
getch();
}

Is This Answer Correct ?    14 Yes 30 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is putchar() function?

1163


What is spaghetti programming?

1139


What is #line used for?

1028


How can I read/write structures from/to data files?

976


What is the right type to use for boolean values in c? Is there a standard type? Should I use #defines or enums for the true and false values?

1061


Explain 'far' and 'near' pointers in c.

1144


Can we declare variable anywhere in c?

979


Is it fine to write void main () or main () in c?

1031


How can a string be converted to a number?

1023


How can type-insensitive macros be created?

1171


Tell me when would you use a pointer to a function?

1066


How can you be sure that a program follows the ANSI C standard?

1613


Write the syntax and purpose of a switch statement in C.

1109


Write a code to determine the total number of stops an elevator would take to serve N number of people.

1259


What is a c token and types of c tokens?

1069