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 how can you be sure that a program follows the ansi c standard?

1392


What are the types of pointers in c?

969


What does %c mean in c?

1025


What is the meaning of 2d in c?

1060


What is the difference between struct and union in C?

1236


What is a void pointer in c?

1033


If I have a char * variable pointing to the name of a function ..

1110


What is the most efficient way to store flag values?

1122


in multiple branching construct "default" case is a) optional b) compulsarily c) it is not include in this construct d) none of the above

1012


Explain how are 16- and 32-bit numbers stored?

1205


Is null always defined as 0(zero)?

1039


What are predefined functions in c?

1017


Is struct oop?

955


code for find determinent of amatrix

1909


What is c method?

939