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

Try it. It will seriously work. You would appreciate it.

#include<stdio.h>
#include<conio.h>

int main()

{
int x;
int a;
int b;
int c;
int d;
int e;
int sum;

printf("Please enter a five digit number:\n");
scanf("%d",&x);

a=x%10;
b=(x/10)% 10;
c=(x/100)% 10;
d=(x/1000)%10;
e=(x/10000)%10;

sum=a+b+c+d+e;

printf("\n\nThe sum of all digits is %d.",sum);

getch();
return 0;

}

Is This Answer Correct ?    12 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can we assign string to char pointer?

1097


Write a program to print all permutations of a given string.

1190


What is the difference between int main and void main?

1042


What is time null in c?

1069


What is pivot in c?

1024


What is null pointer in c?

984


can any one provide me the notes of data structure for ignou cs-62 paper

2171


Is c object oriented?

962


What does 3 periods mean in texting?

1054


Write the control statements in C language

1198


How can I run c program?

1163


Difference between Function to pointer and pointer to function

1065


What is the use of parallelize in spark?

1026


I have seen function declarations that look like this

1040


what are non standard function in c

1906