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...

how to find sum of digits in C?

Answer Posted / jay soni

#include<stdio.h>
#include<conio.h>
void main()

{
int n,sum=0,r;
printf("enter the value");
scanf("%d",&n);
while(n>0)
{
r=n%10;
n=n/10;
sum=sum+r;
}
printf("\nsum of digits is %d",sum);

getch();
}

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What does *p++ do?

1029


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

1142


show how link list can be used to repersent the following polynomial i) 5x+2

2317


What does it mean when the linker says that _end is undefined?

1105


What are the 3 types of structures?

1035


What is the difference between abs() and fabs() functions?

1137


If one class contains another class as a member, in what order are the two class constructors called a) Constructor for the member class is called first b) Constructor for the member class is called second c) Only one of the constructors is called d) all of the above

1072


Why does not c have an exponentiation operator?

1061


What is null in c?

1103


How are 16- and 32-bit numbers stored?

1293


List some of the static data structures in C?

1204


Explain About fork()?

1124


How can you increase the allowable number of simultaneously open files?

1167


What are actual arguments?

1108


What is the difference between malloc() and calloc() function in c language?

1091