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

Is there a way to have non-constant case labels (i.e. Ranges or arbitrary expressions)?

1065


What are global variables and explain how do you declare them?

1096


Is null always defined as 0(zero)?

1099


What is declaration and definition in c?

1085


count = 0; for (i = 1;i < = 10; i++);count = count + i; Value of count after execution of the above statements will be a) 0 b) 11 c) 55 d) array

1088


Explain what does a function declared as pascal do differently?

1276


What is the use of ?

1035


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

2188


How main function is called in c?

1121


i have to apply for rbi before that i need to know the the syllabus for the entrance questions. whethet it may be aps or techinical

2321


Write an efficient algo and C code to shuffle a pack of cards.. this one was a feedback process until we came up with one with no extra storage.

1061


How can you convert integers to binary or hexadecimal?

1022


What is meant by high-order and low-order bytes?

1047


Define C in your own Language.

1072


Are the variables argc and argv are always local to main?

1020