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 collection of functions,calls,subroutines or other data a) library b) header files c) set of files d) textfiles

1184


The statement, int(*x[]) () what does in indicate?

1158


What is the process of writing the null pointer?

1031


differentiate built-in functions and user – defined functions.

1101


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

1088


The % symbol has a special use in a printf statement. Explain how would you place this character as part of the output on the screen?

1217


Difference between pass by reference and pass by value?

1166


write a program using linked list in which each node consists of following information. Name[30] Branch Rollno Telephone no i) Write the program to add information of students in linked list

2812


‎How to define structures? · ‎

1102


How can I implement sets or arrays of bits?

1049


What do you mean by c what are the main characteristics of c language?

1039


is it possible to create your own header files?

1107


How is pointer initialized in c?

1033


What is %s and %d in c?

1049


Why do we use static in c?

1141