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

Explain what is the difference between text files and binary files?

1095


What do you mean by invalid pointer arithmetic?

998


How do you determine the length of a string value that was stored in a variable?

1078


What is the use of pointers in C?

1021


write a c program to find the sum of five entered numbers using an array named number

2073


What is structure data type in c?

967


Explain the use of #pragma exit?

1107


what is a function method?give example?

2309


Describe the steps to insert data into a singly linked list.

1016


What is c language and why we use it?

999


A routine usually part of the operation system that loads a program into memory prior to execution a) linker b) loader c) preprocessor d) compiler

1049


What is a header file?

1026


What are static variables in c?

1026


What is the difference between null pointer and wild pointer?

1134


praagnovation

2218