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

#include<stdio.h>
#include<conio.h>
int main()
{
int n,m,d,m1,s=0,s1;
printf("enter the number ");
scanf("%d",&n);
m=n%10;
d=n/10;
while(d>=10)
{
m1=d%10;
d=d/10;
s=s+m1;
}
s1=s+m+d;
printf("\nThe sum of digits is ");
printf("%d",s1);
getch();
}

Is This Answer Correct ?    7 Yes 11 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Write a c program to build a heap method using Pointer to function and pointer to structure ?

4625


What are the storage classes in C?

1075


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

1087


What is quick sort in c?

1023


What is C language ?

1904


Who is the founder of c language?

1110


4-Take two sets of 5 numbers from user in two arrays. Sort array 1 in ascending and array 2 in descending order. Perform sorting by passing array to a function mySort(array, sortingOrder). Then multiply both the arrays returned from function, using metric multiplication technique in main. Print result in metric format.

2139


When should we use pointers in a c program?

1083


How can I get back to the interactive keyboard if stdin is redirected?

1137


What is a protocol in c?

951


What is union in c?

1062


What is cohesion and coupling in c?

987


What is the c language function prototype?

1044


What is class and object in c?

1051


What is an endless loop?

1234