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

Explain heap and queue.

1097


What is variables in c?

1055


Do pointers store the address of value or the actual value of a variable?

1084


What are the 32 keywords in c?

1094


Why cant I open a file by its explicit path?

1039


How many levels of indirection in pointers can you have in a single declaration?

1094


Is c easier than java?

1086


How to compare array with pointer in c?

1117


Can the “if” function be used in comparing strings?

1061


Which is better malloc or calloc?

1110


what is the structure pointer?

2133


Write a program to print all permutations of a given string.

1203


What is local and global variable in c?

1210


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

1097


Why do some versions of toupper act strangely if given an upper-case letter?

1079