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...

Program to find the sum of digits of a given number until
the sum becomes a single digit

Answer Posted / ashutosh shashi

int n = 123456789; //any numer of you want sum
int sum = 0;
while (n > 0)
{
int p = n % 10;
sum = sum + p;
n = n / 10;
if(n==0 && sum>9)
{
n=sum;
sum=0;
}
}
printf("%d",sum);

Is This Answer Correct ?    157 Yes 63 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

a sequence of bytes with one to one corrspondence to those in the external device a) sequential addressing b) address c) byte code d) none

1200


Write a program for finding factorial of a number.

1029


what is the basis for selection of arrays or pointers as data structure in a program

4248


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


Is c language still used?

932


How can a process change an environment variable in its caller?

1127


What is a null pointer assignment error? What are bus errors, memory faults, and core dumps?

1375


What does sizeof int return?

1021


Explain pointer. What are function pointers in C?

1012


What is static volatile in c?

969


Using functions, write a program that multiplies two arrays. Use the following functions: - Function ReadArray - Function MultiplyArrays - Function DisplayArrays

2296


Explain bit masking in c?

1079


Are comments included during the compilation stage and placed in the EXE file as well?

1026


Which one would you prefer - a macro or a function?

1031


What is the difference between text and binary i/o?

995