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

Why is it that not all header files are declared in every C program?

1229


Explain data types & how many data types supported by c?

1086


What is structure data type in c?

1030


Why c is a procedural language?

1078


Is c# a good language?

1019


what is different between auto and local static? why should we use local static?

1128


What is a class c rental property?

1102


How many identifiers are there in c?

1027


What is selection sort in c?

1109


What is structure packing in c?

1085


.find the output of the following program? char*myfunc(char*ptr) { ptr +=3; return (ptr); } int main() { char*x,*y; x="HELLO"; y=myfunc(x); printf("y = %s ",y); return 0; }

2592


What are categories used for in c?

1104


a function gets called when the function name is followed by a a) semicolon (;) b) period(.) c) ! d) none of the above

1397


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

1261


Explain how do you list a file’s date and time?

1043