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

What is a global variable in c?

972


What are qualifiers in c?

999


Can math operations be performed on a void pointer?

1013


What is the purpose of main( ) in c language?

1112


Difference between exit() and _exit() function?

1094


What are multidimensional arrays?

1086


Why cant I open a file by its explicit path?

1008


How can you draw circles in C?

1110


What is meant by type specifiers?

1094


Are the variables argc and argv are always local to main?

986


How will you declare an array of three function pointers where each function receives two ints and returns a float?

1316


What is the use of parallelize in spark?

997


How can I do graphics in c?

995


Why is it important to memset a variable, immediately after allocating memory to it ?

2022


What is the difference between struct and typedef struct in c?

1099