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 / areeb ahmed khan

#include<stdio.h>
#include<conio.h>
main()
{
int a,b,c,d,e;
int digit,number,sum;

printf("\n\n\n");

printf("Enter a five-digit number :");
scanf("%d",&number);

digit=number%10;
a=digit;

number=number/10;
digit=number%10;
b=digit;

number=number/10;
digit=number%10;
c=digit;

number=number/10;
digit=number%10;
d=digit;

number=number/10;
digit=number%10;
e=digit;

sum=a+b+c+d+e;
printf("\nThe sum of five-digit number is : %d",sum);

getch();
}

Is This Answer Correct ?    7 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a good data structure to use for storing lines of text?

1032


What is the difference between ‘g’ and “g” in C?

3905


What is the value of a[3] if integer a[] = {5,4,3,2,1}?

1028


What is this pointer in c plus plus?

1023


What is adt in c programming?

1095


How can I remove the leading spaces from a string?

1095


What is the difference between the = symbol and == symbol?

1052


In which layer of the network datastructure format change is done

1835


A collection of data with a given structure for excepting storing and providing on demand data for multiple users a) linked list b) datastructer c) database d) preprocessor

1036


Tell us the use of fflush() function in c language?

1083


What is volatile keyword in c?

995


What is pass by reference in c?

1142


how to build a exercise findig min number of e heap with list imlemented?

2017


Explain what would happen to x in this expression: x += 15; (assuming the value of x is 5)

1216


What’s the special use of UNIONS?

1104