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

What are the key features in c programming language?

1026


Is it possible to initialize a variable at the time it was declared?

1197


Difference between linking and loading?

1079


Explain the difference between getch() and getche() in c?

957


Who is the founder of c language?

1132


What is putchar() function?

1104


What is %g in c?

1035


What is data type long in c?

1038


What is extern keyword in c?

1102


Function calling procedures? and their differences? Why should one go for Call by Reference?

1059


When should a type cast be used?

984


provide an example of the Group by clause, when would you use this clause

2155


How do I get an accurate error status return from system on ms-dos?

1092


What is the difference between array and structure in c?

1113


Explain what is wrong with this statement? Myname = ?robin?;

1543