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 / aryan garg

#include<stdio.h>
int main()
{
int n,d1,d2,d3,d4,d5,s;
printf("enter a five digit no");
scanf("%d",&n);
d5=n%10;n=n/10;
d4=n%10;n=n/10;
d3=n%10;n=n/10;
d2=n%10;n=n/10;
d1=n%10;
s=d1+d2+d3+d4+d5;
printf("sum of the digits of number is : %d",s);
return 0;
}

Is This Answer Correct ?    0 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why we write conio h in c?

963


write a proram to reverse the string using switch case?

2874


How can I change their mode to binary?

1050


a single linked list consists of nodes a to z .print the nodes in reverse order from z to a using recursion

2714


Why do we use namespace feature?

1003


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

986


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.

1622


Explain the use of function toupper() with and example code?

1076


write an algorithm to display a square matrix.

2638


Differentiate fundamental data types and derived data types in C.

983


Draw a diagram showing how the operating system relates to users, application programs, and the computer hardware ?

2520


What is indirection in c?

1018


How are 16- and 32-bit numbers stored?

1236


Explain is it better to use a pointer to navigate an array of values, or is it better to use a subscripted array name?

1152


a parameter passed between a calling program and a called program a) variable b) constant c) argument d) all of the above

1066