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 / rama krishna sidhartha

int n = 1234; //any numer of you want sum
int sum = 0;
void main()
{
clrscr();
while (n > 0)
{
int p = n % 10;
sum = sum + p;
n = n / 10;
}
printf("%d",sum);
getch();
}

Is This Answer Correct ?    49 Yes 75 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the meaning of 2d in c?

1131


Explain what are the advantages and disadvantages of a heap?

1094


find the output? void r(int a[],int c, int n) { if(c>n) { a[c]=a[c]+c; r(a,++c,n); r(a,++c,n); } } int main() { int i,a[5]={0}; r(a,0,5); for(i=0;i<5;i++) printf("\n %d",a[i]); getch(); }

2316


ATM machine and railway reservation class/object diagram

5254


Is there sort function in c?

1028


What is the time and space complexities of merge sort and when is it preferred over quick sort?

1087


What are the basic data types associated with c?

1280


What is structure and union in c?

1160


What is the scope of global variable in c?

1000


In a switch statement, what will happen if a break statement is omitted?

1069


What is the process of writing the null pointer?

1031


What is the use of pointers in C?

1088


Explain how can a program be made to print the line number where an error occurs?

1226


What is meant by initialization and how we initialize a variable?

1058


Why should I prototype a function?

1209