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 / sanjay m

#include<stdio.h>
#include<conio.h>
void main()
{
unsigned int n,c=0,r,i,S=0;
clrscr();
printf("enter no.");
scanf("%d",&n);
while(n>0)
{
{
r=n%10;
c=c+r;
n=n/10;
}
if(c>9)
{
int X=c%10;
int Y=c/10;
S=X+Y;

}
}
if(c<10)
printf("%d",c);
else
printf("%d",S);
getch();
}

Is This Answer Correct ?    13 Yes 14 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

A text file that contains declarations used by a group of functions,programs,or users a) executable file b) header file c) obj file d) .cfile

1088


Is return a keyword in c?

1073


What is the difference between class and object in c?

1168


What is a #include preprocessor?

1145


What happens if you free a pointer twice?

1067


Write a program to produce the following output: 1 2 3 4 5 6 7 8 9 10

15805


What's the best way of making my program efficient?

1099


What happens if a header file is included twice?

1034


What is the best style for code layout in c?

1095


hi send me sample aptitude papers of cts?

2163


the real constant in c can be expressed in which of the following forms a) fractional form only b) exponential form only c) ascii form only d) both a and b

2672


What is data type long in c?

1076


Is it better to use a pointer to navigate an array of values, or is it better to use a subscripted array name?

1083


What’s the special use of UNIONS?

1152


what is the format specifier for printing a pointer value?

1016