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 / d. prashant

#include<stdio.h>
#include<conio.h>
main()
{
int n,i,sum=0,r;
printf("enter the value");
scanf("%d",&n);
while(n)
{
rem=num%10;
sum=sum+rem;
num=num/10;
}
printf("sum = %d",sum);
}

Is This Answer Correct ?    7 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

When I set a float variable to, say, 3.1, why is printf printing it as 3.0999999?

1071


How can I check whether a file exists? I want to warn the user if a requested input file is missing.

1156


How can I invoke another program (a standalone executable, or an operating system command) from within a c program?

1223


In C language, a variable name cannot contain?

1282


difference between native and cross compilers

2140


Does c have an equivalent to pascals with statement?

1014


Explain what are header files and explain what are its uses in c programming?

1161


What is context in c?

932


Explain what are the __date__ and __time__ preprocessor commands?

1133


Explain how do you override a defined macro?

1085


What is the scope of an external variable in c?

1052


What does int main () mean?

1038


What is a structure in c language. how to initialise a structure in c?

1067


what will be the output for the following main() { printf("hi" "hello"); }

11023


1.int a=10; 2.int b=20; 3. //write here 4.b=30; Write code at line 3 so that when the value of b is changed variable a should automatically change with same value as b. 5.

2161