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 / pooja

main()
{
int n,i,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);
}

Is This Answer Correct ?    57 Yes 11 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do we declare variables in c?

1027


What are the disadvantages of c language?

1144


When can a far pointer be used?

991


What is the best way to store flag values in a program?

1032


What’s a signal? Explain what do I use signals for?

1082


What is the difference between procedural and declarative language?

1111


Explain the properties of union. What is the size of a union variable

1152


Explain how can I manipulate strings of multibyte characters?

1176


Explain what is the difference between text files and binary files?

1121


Explain what is page thrashing?

1068


What are the 5 types of inheritance in c ++?

989


What are types of functions?

1009


What is variable declaration and definition in c?

872


How do you sort filenames in a directory?

1135


What is a macro, and explain how do you use it?

1040